Create a logrotate configuration file
$ vi/etc/logrotate.d/tomcat
Add the following content:
/opt/entermediadb/tomcat/logs/catalina.out { copytruncate daily rotate 7 compress Missingok dateext Size 100m
Parameter description:
Specify the path to the log file. Copytruncate–creates a copy of the log file and then truncates the original to an empty file so that the service can Kee P on logging uninterrupted.daily–rotates the Catalina.out daily.rotate–keeps for most 7 log files. Compress–create a gzip compressed file of the rotated files.missingok–suppresses error messages if the file does not E Xist. Dateext–add the date to the filename of the archived log file.size–rotates if the size of catalina.out is bigger than 100m.
Files can be found on most Linux systems:/etc/cron.daily/logrotate, the file is run every day. The runtime calls:
This will rotate out the tomcat log.
If you have more than one Tomcat instance, you need to configure multiple separate rotation files.
You can also write scheduled tasks manually:
2 * * * */USR/SBIN/LOGROTATE/ETC/MYLOGROTATE.D/TOMCAT
Set up log rotation to avoid a large increase in Tomcat catalina.out files