logrotate_tra.conf File

Use the logrotate_tra.conf file to configure system log rotation behavior for a Traffic Routing Agent (TRA) server deployed in Kubernetes. By default, the log volume is checked on a daily basis to determine if log rotation is needed based on the settings defined in this file.

Default TRA Log Rotation Configuration shows the default values for TRA log rotation in the logrotate_tra.conf file. It describes the values set for the command log, debug log, and process control log.

Depending on your workload and the log level configured for your system, you can change the rotation time period and the log file volume in these files. Typically, you need not change any other parameter values.

You can configure TRA log rotation by adding the logrotate_tra.conf file in a configuration source. When the container starts up, it copies the logrotate* file to the opt/tra/conf directory. To use a different logrotate* file or modify the log rotation interval, edit the process_control_cfg_sed.extra file to replace the command with one that passes the desired time interval value or configuration file name.
Note: You can also modify TRA log rotation parameters in Kubernetes by editing the configuration parameters in the /opt/tra/data/logrotate_tra.conf file before deploying the container.

Default TRA Log Rotation Configuration

This example logrotate_tra.conf file logs messages in the mtx_debug.log file.
Note: Some of the file rotation tools are shared with the mtx user. For example both the mtx and tra users use log files that are named with mtx prefixes.
#
# /etc/logrotate.d/tra
#
# This is a sample logrotate configuration for tra.  
#
# The default configuration for mtx_cmd.log will
#   (1) Rotate 7 times before being removed.
#   (2) The original log file is truncated to zero size in place after
#       creating a copy.  Note: There is a very small time slice between
#       copying the file and truncating it, so some logging data might be
#       lost.
#   (3) Log files are rotated every day.
#   (4) If the log file is missing, go on to the next one without an error.
#   (5) Do not rotate the log if it is empty.
#   (6) Old versions of log files are not compressed.
#   (7) Log file is rotated when it grows bigger than 100M.
#
# The default configuration for mtx_debug.log will
#   (1) Rotate 7 times before being removed.
#   (2) The log file is created immediately after rotation (before the
#       postrotate script is run).
#   (3) Log files are rotated every day.
#   (4) If the log file is missing, go on to the next one without an error.
#   (5) Do not rotate the log if it is empty.
#   (6) Old versions of log files are not compressed.
#   (7) Log file is rotated when it grows bigger than 500M.
#   (8) Send USR2 signal to mtx servers so that it can start using new log
#       log file after the log file is rotated.
#
# The default configuration for tra_process_control.log will
#   (1) Rotate 30 times before being removed.
#   (2) The original log file is truncated to zero size in place after
#       creating a copy.  Note: There is a very small time slice between
#       copying the file and truncating it, so some logging data might be
#       lost.
#   (3) Log files are rotated every day.
#   (4) If the log file is missing, go on to the next one without an error.
#   (5) Do not rotate the log if it is empty.
#   (6) Old versions of log files are compressed with gzip.
#   (7) Postpone compression of the previous log file to the next rotation
#       cycle.
#   (8) Log file is rotated when it grows bigger than 100M.
#   (9) Change file permission of tra_process_control.log file to be readable by
#       'mtx' user after the log file is rotated.
#
# Note: [Optional] Log files can be offloaded at the postrotate step.
#

#
# The path for mtx.log must match with the value specified in 
# /etc/rsyslog.d/20-mtx.conf file.
#
/var/log/tra/mtx_cmd.log "mtx_cmd.log"
{
        rotate 7
        copytruncate
        daily
        missingok
        notifempty
        nocompress
        maxsize 100M
        sharedscripts
        dateext
        dateformat _%Y_%m_%d_%H_%s
        extension .log
        postrotate
                chmod 644 /var/log/tra/mtx_cmd.log
        endscript
}

#
# The path for mtx_debug.log must match with the value specified inside of
# <log_file_name> in mtx_config.xml file.
#
/var/log/tra/mtx_debug.log "mtx_debug.log"
{
        rotate 7
        create
        daily
        missingok
        notifempty
        nocompress
        maxsize 500M
        sharedscripts
        dateext
        dateformat _%Y_%m_%d_%H_%s
        extension .log
        postrotate
                if killall -q -s0 -utra mtx; then
                        killall -q -USR2 -utra mtx
                fi
        endscript
}

#
# The path for tra_process_control.log must match with the value specified in 
# /etc/rsyslog.d/20-mtx.conf file.
#
/var/log/tra/tra_process_control.log "tra_process_control.log"
{
        rotate 30
        copytruncate
        daily
        missingok
        notifempty
        compress
        delaycompress
        maxsize 100M
        sharedscripts
        dateext
        dateformat _%Y_%m_%d_%H_%s
        extension .log
        postrotate
                chmod 644 /var/log/tra/tra_process_control.log
        endscript
}