Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How do I configure commons-logging for use with Tomcat?

Wiki Markup
You need to specify a commons-logging configuration file and, if you wish, a logging implementation that supports commons-logging. JDK 1.4 (and later) java.util.Logging and Log4j are the two most commonly used logging toolkits for Tomcat. If you supply an external logging toolkit such as Log4J, it needs to be located in the $CATALINA_HOME/common/lib directory (for Tomcat 5.0 and
earlier) or added to the bootstrap classpath by using the scripts in
 earlier). Tomcat 5.5 and later uses commons-logging  while bootstrapping so some people suggest adding Log4j to the bootstrap classpath by using the scripts in $CATALINA_HOME/bin
(this is required for Tomcat 5.5 and later, which uses commons-logging while bootstrapping, and optional for Tomcat 5.0 and earlier
 (see \[http://markmail.org/message/3sgxfol3njcfutsm Need for it to be in bootstrap classpath?\]). A better approch apparently working is:

  1. Put jog4j.jar in the $CATALINA_HOME/common/lib directory 2. Put the full commons-logging.jar in the $CATALINA_HOME/common/lib directory, even if you see the reduced API version there, named commons-logging-api.jar

Wiki Markup
Through some classloading voodoo during bootstrapping, if you have the full commons-logging.jar file in your common/lib directory, it replaces the classes from the commons-logging-api.jar file and will reinitialize the logging system and attempt to locate log4j or whatever other logging system you may be using. (see \[http://markmail.org/message/3sgxfol3njcfutsm#query:+page:1+mid:7oce37bngiq2otlu+state:results this thread).

For more detailed instructions, see these mailing list discussions:

  • Wiki Markup
    \[http://marc.theaimsgroup.com/?l=tomcat-user&m=106623436423859&w=2 A log4j example\]
  • Wiki Markup
    \[http://marc.theaimsgroup.com/?l=tomcat-user&m=108330970225012&w=2 Logging Configuration\]
  • Wiki Markup
    \[http://marc.theaimsgroup.com/?l=tomcat-user&m=108578233003073&w=2 Example with JSVC and running on port 80.\]
  • Wiki Markup
    \[http://markmailminaret.orgbiz/message/3sgxfol3njcfutsm Need for it to be in bootstrap classpath.tips/tomcatLogging.html Tomcat and Log4j Configuration (and Velocity), addressing and solving the bootstrap commons-logging.jar problem\]
    \\

How should I log in my own webapps?

...