- Core:
- Full documentation:
- Deployer:
-
Extras:
- JMX Remote jar (pgp, md5)
- Web services jar (pgp, md5)
- JULI adapters jar (pgp, md5)
- JULI log4j jar (pgp, md5)
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 logging.properties or log4j.properties 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/catalina.sh 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:
touch "$CATALINA_OUT"
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/catalina.sh
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.
Popular Links
Comments
tomcat.pid
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 catalina.sh. --- if
I modify catalina.sh.
---
if [ ! -z "$CATALINA_PID" ]; then
$JAVA_HOME/bin/jps | grep "Bootstrap" | cut -d " " -f 1 > $CATALINA_PID
#echo $! > $CATALINA_PID
fi
---
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
Post new comment