Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added more text on JULI and an image. Hope it's correct, but looking at the source says yes.

...

  • Prior to Tomcat 5.5, Tomcat provided a Logger element that you could configure and extend according to your needs.
  • Starting with Tomcat 5.5, Logger was removed and Apache 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.htmlTo enable request logging similar to the Apache HTTP server, you may include the following line
  • In Tomcat 7 (and also 6), the logging code is based on a set of classes interacting with the java.util.logging API (JUL), which comes with Java since version 1.4. The Tomcat startup script configures the JVM to uses a web-application-aware implementation of the JUL LogManager. This Tomcat logging infrastructure is called JULI, and one can still distinguish its Apache Commons Logging heritage, but the complex configuration has been edited out and the package name changed.

http://public.m-plify.net/TomcatLogging.png

Web applications can get logging service by using the Servlet API logging (which not recommended), the JUL interface (which ultimately goes to JULI) or any other preferred interface for which they furnish the jar files and the appropriate configuration (see the respective descriptions for Log4J, SLF4J, logback or Apache Commons Logging for example).

To additionally log information about requests going to the web application, "Valves" can be configured in the server.xml file, as described in detail here. For example, inside the <Engine> tag:

  • <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.

...