Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Expanded the section on rotating catalina.out

...

  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 logging.properties file?
  10. Since java.logging is the default commons-logging implementation in Tomcat, why is it not working in my Linux distribution?

...

Anchor
Q6
Q6
Where does System.out go? How do I rotate catalina.out?

System.out and System.err are both print to redirected to CATALINA_BASE/logs/catalina.out when using Tomcat's startup scripts (bin/startup.sh/.bat or bin/catalina.sh/.bat). Any code that writes to System.out or System.err will end up writing to that file.

If your webapp uses System.out and/or System.err a lot, . But you can suppress this via the swallowOutput property and sent 'swallowOutput' attribute in your <Context> configuration element and send to different log files (configured elsewhere: see the documentation for configuring logging).

Anchor
Q10
Q10
How do I rotate catalina.out?

CATALINA_BASE/logs/catalina.out does not rotate. But it should not be an issue because nothing should be printing to standard output since you are using a logging package, right? thread about rotation of catalina.out

If you really must rotate catalina.out, here are some techniques you can use:

  1. If you are using jsvc 1.0.4 or later to launch Tomcat, you can send SIGUSR1 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' or 'rename') to re-name catalina.out at intervals and then get jsvc to re-open the original (catalina.out) file and continue writing to it. Note that Tomcat's win32 service is the same thing as jsvc, but you may have difficulty sending SIGUSR1 in a win32 environment.
  2. Use 'logrotate' with the 'copytruncate' option. This allows you to externally rotate catalina.out without changing anything within Tomcat.
  3. Modify bin/catalina.sh/.bat to pipe output from the JVM into a piped-logger such as chronolog 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).

References to mailing list discussions:

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

...