Versions Compared

Key

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

...

  • Prior to Tomcat 5.5, Tomcat provided a Logger element that you could configure and extend according to your needs. If you are using a Tomcat version previous to Tomcat 5.5, make sure to read the Logger configuration reference.
  • Starting with Tomcat 5.5, Logger was removed and Jakarta Commons-Logging Log is used everywhere in Tomcat. Read the Commons-Logging documentation if you'd like to know how to better use and configure Tomcat's internal logging. See also http://tomcat.apache.org/tomcat-5.5-doc/logging.html
  • Wiki MarkupTo enable request logging similar to the Apache HTTP server, you may include the following line in the server.xml file, in the <Engine> tag: <Valve
    • <Valve className="org.apache.catalina.valves.AccessLogValve"
      • directory="logs"
      • prefix="localhost_access_log."
      • suffix=".log"
      • pattern="common"
      • resolveHosts="false"/>
    • This
    • will
    • produce
    • a
    • log
    • file
    • for
    • each
    • day,
    • such
    • as
    • logs/localhost_access_log.2008-03-10.log,
    • containing
    • the
    • files
    • requested,
    • IP
    • address
    • of
    • the
    • requester,
    • and
    • similar
    • information.
      • Wiki Markup
        128.34.123.121 - - \[10/Mar/2008:15:55:57 -0500\] "GET /upload/ClickPoints.jsp HTTP/1.1" 200 2725
        
    \
      • \
      • \
    \

In addition, Tomcat does not swallow the System.out and System.err JVM output streams. You may use these streams for elementary logging if you wish, but a more robust approach such as commons-logging or Log4J is recommended for production applications.

...

Tomcat wants to support multiple logging implementations, so it uses commons-logging. In case that's unclear, think of it like this. You are a Tomcat developer. The car you drive when logging is the commons-logging car. The engine of that car is either JULI or log4j. Without one of these engines, the car goes no where. However regardless of whether you use JULI or log4j, the steering wheel, break, gas pedal, etc. are the same.

Related FAQ:
What role does JULI and log4j play in logging?

Anchor
Q3
Q3
What role does JULI and log4j play in logging?

First see:
What role does commons-logging play in logging?

...

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. Tomcat 5.5 and Tomcat 6.0 use java.logging as default implementation for commons-logging. So this should work by default, but sometimes it doesn't (see Need for it to be in bootstrap classpath?]). 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). 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 (see [http://markmail.org/message/3sgxfol3njcfutsm). A better approch apparently working is:

  1. Put jog4jlog4j.jar in the $CATALINA_HOME/common/lib directory
  2. 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

...

java.util.logging.config.file

Example:
-Djava.util.logging.config.file=/etc/tomcat/logging.properties

...

Wiki Markup
\# Set juli [LogManager] if it is present if \[-r "$CATALINA_BASE"/conf/logging.properties \]; then
   

  • JAVA_OPTS="$JAVA_OPTS

...

  • "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"

...

  • "-Djava.util.logging.config.file="$CATALINA_BASE/conf/

...

  • logging.properties"

fi

Projects such as JPackage that repackage Tomcat for Linux typically move the configuration to a directory dictated by the FHS standard (http://www.pathname.com/fhs/), and therefore use the java.util.logging.config.file property to set the location of the logging.properties file in the Tomcat startup script.

...

  • look for what Tomcat version you got installed with: yum list installed tomcat5

Since I had the 5.5.23, I downloaded the Tomcat Binaries 5.5.23 from http://archive.apache.org/dist/tomcat/, then:

  • tar xf apache-tomcat-5.5.23.tar.gz
  • cd apache-tomcat-5.5.23/bin
  • cp tomcat-juli.jar /usr/share/tomcat5/bin/

Restart Tomcat... and it's working!