How to configure a log rotation for the Tomcat’s catalina.out log file

As catalina.out is Tomcat's log, Artifactory doesn't have any control over its rotation.

However, on a Linux OS you can do the following:


  1. Create a configuration file in the following path: /etc/logrotate.d/ . For example: /etc/logrotate.d/tomcat
  2. Insert the following to the above file:
    /{PATH_TO_CATALINA_FILE}/catalina*.* {
    rotate 7
    size 100M

The following parameters are used for:

  • copytruncate - truncates the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one.
  • daily - rotate the log every day.
  • rotate - how many rotation logs to keep.
  • compress - If this value is written the log will be compressed.
  • missingok - If the log file is missing, go on to the next one without issuing an error message.
  • size #M - specify the size of the file before rotation.

You can run the rotation by adding a cron task. For example, define it on the /etc/cron.hourly/, or run this task manually by running /usr/sbin/logrotate /etc/logrotate.conf

Note: There is a very small time slice between copying the file and truncating it, so some logging data might be lost.