Rotating catalina.out log files

posted by SpringSource on June 28, 2010 09:58 AM

It is possible to rotate the catalina.out log, by using a log rotation program like rotatelogs or cronolog.

It is possible to rotate the catalina.out log, but it is not controlled by the standard or files.

The catalina.out log is stderr and stdout piped to a file. If you want to rotate this log file you will need to use a log rotation program like rotatelogs or cronolog. Then just pipe to the log rotation program rather than the file.

Here is an example of how to do this with cronolog. Using another program would be very similar, the command in step #3 would just be slightly different.

1.) Edit the bin/ file.

2.) Find the following line and comment it out.

touch "$CATALINA_BASE"/logs/catalina.out

Note that in later versions of Tomcat this may look like:


3.) Find the following line (there should be two instances of this line, replace both)

>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &

and replace it with this line

2>&1 |/usr/bin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &

Note that in later versions of Tomcat the line that needs to be replaced may look like:

>> "$CATALINA_OUT" 2>&1 &

4.) Save bin/

5.) Restart Tomcat.

You should now have a "catalina-2010-03-30.out" file in your logs directory. When the date changes a new log file will be created. The following day you should see "catalina-[following date].out".

Please note that the log file may not be rotated exactly at midnight. It will rotate the first time something is written to the log after the date has changed. This generally isn't a problem for busy log files.

For more than 10 years, SpringSource employees have been supporting Apache technologies, with unparalleled experience and commitment to the Apache Software Foundation. More than 400 of the Fortune 500 count on SpringSource to support their mission-critical business applications. Leaders of the Apache Software Foundation, including Board Members, work at SpringSource and dedicate a significant amount of time further developing the Apache Tomcat open source project. Over the last 2 years, 95% of the issues fixed in the Apache Tomcat project were fixed by SpringSource engineers. For more information on how SpringSource can help your enterprise, see the SpringSource website, or call 800/444-1935.


Using "2>&1 |/usr/bin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &" means the tomcat pid file doesn't contains anymore the pid of the java process but the cronlog pid

I modify --- if

I modify

if [ ! -z "$CATALINA_PID" ]; then
$JAVA_HOME/bin/jps | grep "Bootstrap" | cut -d " " -f 1 > $CATALINA_PID
#echo $! > $CATALINA_PID

but a little ugly.

And as a windows service?

Is it possible to rotate stdout.log when running tomcat as a windows service? Is this possible? Regards, Martin

If using the TanukiSoft wrapper...

it is certainly possible; consult the docs at

logrotate can be used


RE: Rotating catalina.out log files

For Linux systems run a logrotate script and adjust the parameters as needed following logrotate man page. Set logrotate script to run via cron.daily program.

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.