In this article, we'll focus on the two most common logging implementations used for Tomcat - the included JULI implementation, and Log4J, a popular, feature-rich implementation compatible with JCL.
Meet JULI - Java Utility Logging Implementation Although all JDKs ship with logging functionality provided by logging, this default implementation is not designed for container-based environments.
However, spending some time familiarizing yourself with the logging options available in Tomcat can save you valuable time if you find yourself dealing with an unexpected issue.
Thanks to Tomcat's JCL support, configuring Log4J for the first time is a fairly painless process. Container Base.[Catalina].[localhost].[/].[jsp] = ALLYou can also use this syntax and configuration layout on a per-application basis by including a custom "log4j.properties" in "WEB-INF/classes" and copying log4jx.y.to "WEB-INF/lib".
However, before you get started, you'll have to download replace Tomcat's included JCL support, which is hard-coded for use with JULI, with a full version of JCL. A final word of warning: when configuring Log4J, you should be aware that low threshold settings such as DEBUG or ALL are extremely verbose, and will noticeably slow Tomcat's startup time.
Now that Tomcat is ready to work with Log4J, download the logger from the project website, and place "log4jx.y.z.jar" in "$CATALINA_HOME/lib". Since you won't be using logging.properties for configuration anymore, you'll have to create log4j.properties in "$CATALINA_HOME/lib".
Eventually, you'll want to modify this file to take advantage of the many features Log4J will make available to you, but for now you can just use the basic configuration recommended by Apache.