...
- Does Tomcat have built-in logging capabilities, and if so how do I use them?
- What role does commons-logging play in logging?
- What role does JULI and log4j play in logging?
- How do I configure commons-logging for use with Tomcat?
- How should I log in my own webapps?
- Where does System.out go?
- How do I rotate catalina.out?
- Where are the logs when running Tomcat as a Windows service?
- How do I customize the location of the tomcat logging.properties file?
- Since java.logging is the default commons-logging implementation in Tomcat, why is it not working in my Linux distribution?
...
Anchor | ||||
---|---|---|---|---|
|
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 | ||||
---|---|---|---|---|
|
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:
- 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.
- Use 'logrotate' with the 'copytruncate' option. This allows you to externally rotate catalina.out without changing anything within Tomcat.
- 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:
- tomcat-user thread from 2003
- tomcat-user thread from 2009
- tomcat-user thread from 2011
- tomct-user thread from 2012
Anchor | ||||
---|---|---|---|---|
|
...