This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Page tree

Versions Compared


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


This FAQ section provides help with logging-related issues.

As you read these questions, please keep in mind that Tomcat's internal logging is separate from your own webapp's logging. You would typically be concerned only with your own webapp's logging. You would modify Tomcat's internal logging settings if you are debugging a possible issue or running into other problems. It is anticipated that Tomcat's out-of-the-box logging configuration will be fine for the vast majority of users and environments.


  1. Does Tomcat have built-in logging capabilities, and if so how do I use them?
  2. What role does commons-logging play in logging?
  3. What role does JULI and log4j play in logging?
  4. How do I configure commons-logging for use with Tomcat?
  5. How should I log in my own webapps?
  6. Where does System.out go?
  7. How do I rotate catalina.out?
  8. Where are the logs when running Tomcat as a Windows service?
  9. How do I customize the location of the tomcat file?
  10. Since java.logging is the default commons-logging implementation in Tomcat, why is it not working in my Linux distribution?


Does Tomcat have built-in logging capabilities, and if so how do I use them?


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

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 - - 
      [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?

What role does JULI and log4j play in logging?

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

Note in addition that in your own applications you could log directly with JULI or log4j. But once you choose one, you can't easily switch to the other later. If you use commons-logging you can.


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 #Q9).

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 Need for it to be in bootstrap classpath?). A better approach apparently working is:

  1. Put log4j.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

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 this thread).


How should I log in my own webapps?


  1. If you are using jsvc 1.0.4 or later (from Apache Commons Daemon project) to launch Tomcat, you can send SIGUSR1 signal to jsvc to get it to re-open its log files (Jira Ticket). You can couple this with 'logrotate' or your favorite log-rotation utility (including good-old 'mv') to re-name catalina.out at intervals and then get jsvc to re-open the original (catalina.out) file and continue writing to it.
  2. Use 'logrotate' with the 'copytruncate' option. This allows you to externally rotate catalina.out without changing anything within Tomcat.
  3. Modify bin/ (or bin/catalina.bat) to pipe output from the JVM into a piped-logger such as cronolog or Apache httpd's rotatelogs (note that the previous reference is for Apache httpd documentation and *is not applicable to Tomcat* – it merely illustrates the concept).
    See also the patch in Bug 53930, "Allow capture of catalina stdout/stderr to a command instead of just a file".

References to mailing list discussions:

Where are the logs when running Tomcat as a Windows service?


How do I customize the location of the tomcat file?


For another example of how to set this look in for Tomcat 6.0.16 on lines 182-185. The statements look like this:


# Set juli LogManager if it is present
if [ -r "$CATALINA_BASE"/conf/ ]; then
  JAVA_OPTS="$JAVA_OPTS "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" "-Djava.util.logging.config.file="$CATALINA_BASE/conf/"


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


  1. tomcat-juli.jar should be in your $CATALINA_HOME/bin directory
  2. tomcat startup script should run java with -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  3. tomcat startup script should run java with -Djava.util.logging.config.file=<some_path>/
  4. obviously, the file must exist in the directory specified in the tomcat script at point #3

If you don't know where to look for your Tomcat startup script, see the previous How do I customize the location of the tomcat file?

In RHEL5 (RedHat Enterprise Server 5) the Tomcat 5.5 rpm installation does not include the tomcat-juli.jar file. This is what I made:

  • 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, 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!