As stated above the default logging supplied by the Java packages does not have the ability to distinguish between different web applications because all the configuration is done at the VM level. For this reason Tomcat 5.5.9 replaces the default LogManager with a more web application friendly implimentation called JULI (Note: on the Tomcat site it implies that all 5.5.x versions include JULI but it wasn't actually included until 5.5.9). To configure JULI you can place a file called logging.properties in the the directory $CATALINA_HOME/common/classes or in your web applications WEB-INF/classes directory. The format of the file is very similar to that of the default Java configuration but it has some additional options that allow it to set up logging on a per-web application basis.
The most important extenstion is to the handler definitions. Each handler can take an optional prefix which takes the form of a numeral followed by any alphanumerics and ends with a ".". For instance a valid perfix would be "7foo.". This lets you define different handlers for different loggers and configure them separatly. Loggers are still shared at the VM level but you can at least now turn sections of logging on and off. For instance to define handlers for the logger "com.crazysquirrel" you might place a file such as this in the WEB-INF/class directory of your web application
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
org.apache.juli.FileHandler.level=ALL
org.apache.juli.FileHandler.directory=${catalina.base}/logs
org.apache.juli.FileHandler.prefix=cs-logging-test-
java.util.logging.ConsoleHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
Posted in: