Configuring Log Rotation for Tomcat

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

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.

  1. Create a configuration file, tomcat, in the following location: /etc/logrotate.d

  2. 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.

  3. 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