If catalina.out becomes 2GB in size, tomcat crashes and fails to start without any error message. To avoid this scenario you should rotate catalina.out frequently. This article describes how to setup autorotation of catalina.out on a linux/unix machine. How to automatically rotate catalina.out dail 1. Create this file
1./etc/logrotate.d/tomcat
2.Copy the following contents into the above file
/var/log/tomcat/catalina.out {
copytruncate
daily
dateext
rotate 7
compress
missingok
}
About the above configuration:
Make sure that the path /var/log/tomcat/catalina.outabove is adjusted to point to your tomcat’s catalina.out
Every night the cron daemon runs jobs listed in the /etc/cron.daily/directory
This triggers the /etc/cron.daily/logrotatefile which is generally shipped with linux installations. It runs the command“/usr/sbin/logrotate /etc/logrotate.conf“
The /etc/logrotate.confincludes all scripts in the/etc/logrotate.d/ directory.
Thistriggers the /etc/logrotate.d/tomcatfile thatyou wrote in the previous step.
Run logrotate manually
Run the following command to run the cron job manually
1./usr/sbin/logrotate /etc/logrotate.conf
More logrotate options
To see all logrotate options on your system, see the manual:
manlogrotate