Since Tomcat is outside the control of Artifactory, you must manually set up log rotation for the Tomcat logs to manage log files.
The following example shows how to set up log rotation for the catalina.out
log in a Linux system.
- Create a configuration file,
tomcat
, in the following location: /etc/logrotate.d Enter the following into
/etc/logrotate.d/tomcat
./{PATH_TO_CATALINA_FILE}/catalina*.* { copytruncate daily rotate 7 compress missingok size 100M }
The following table describes the parameters in the file.
Parameter Description copytruncate Truncates the original log file in place after creating a copy instead of moving the old log file and creating a new one. daily Rotate the log every day. rotate The number of rotation logs to keep. compress Compress the log file. missingok If a log file is missing, skip to the next file without throwing an error message. size #M Maximum size of the file in megabytes. Add a cron task to run log rotation automatically. For example, add the task in
/
etc/cron.hourly/
to run rotation on an hourly basis.You can also run the task manually by running
/usr/sbin/logrotate /etc/logrotate.conf
.
There is a very small time slice between copying the file and truncating it. Therefore, some logging data might be lost