Tuesday, March 31, 2009

Java Logging API and How To Use It

Java Logging API and How To Use It

On tomcat 5.5 we have the JULI library which replaces the standard java logger.
So to get per-context logging, put
logging.properties into WEB-INF/classes with the following contents:
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

org.apache.juli.FileHandler.level = FINE
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
org.apache.juli.FileHandler.prefix = myapp-prefix.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

ps: here are the standard set of JULI properties:
  • org.apache.juli.FileHandler.directory
  • org.apache.juli.FileHandler.prefix
  • org.apache.juli.FileHandler.suffix
  • org.apache.juli.FileHandler.level
  • org.apache.juli.FileHandler.filter
  • org.apache.juli.FileHandler.formatter

No comments: