#
# Rotate the Perforce Helix Swarm server log files
# We need to account for both a single-P4D setup, and a multi-P4D setup.
#
/opt/perforce/swarm/data/log
/opt/perforce/swarm/data/servers/*/log
{
    # Choose rotation frequency and  criteria to suit your site needs.
    #
    # rotate N
    # daily, weekly, monthly
    # size, maxsize, minsize
    #
    # Every day, if the log file is greater than 100k in size then
    # we will rotate the file. We keep the last 14 log files. 
    # Remove minsize if you always want to rotate the logs each day.
    rotate 14
    minsize 100k
    daily
    create
    
    # Don't raise an error if the files are missing. Allows us to
    # specify both single and multi-p4d without causing error.
    missingok

    # Rename/move the log rather than copying because copying isn't
    # necessary and takes longer.
    nocopy

    # Old versions of the log are compressed with gzip by default. You
    # probably want to do this to save disk space but ensure you also
    # use the delaycompress option. See below. Typically, Swarm server
    # logs compress to 10% of their original size.
    compress

    # Postpone compression of the previous log to the next rotation
    # cycle because there may be worker threads that still have the
    # freshly rotated log open. Take care if you are rotating logs
    # very frequently as you don't what to be trying to delete logs
    # that Swarm still has open.
    delaycompress
}
