Configuring Log Rotation for Tomcat
Since Tomcat is outside the control of Artifactory, you must manually set up log rotation for the Tomcat logs.
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 in
/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.
Note
You can also run the task manually by running
/usr/sbin/logrotate /etc/logrotate.conf.
Warning
There is a very small time slice between copying the file and truncating it. Therefore, some logging data might be lost
Updated about 1 month ago
