Rotating log files

  • Article ID: 11486
  • Updated: 10 Mar 2011

PureMessage for UNIX log files must be periodically cleared to avoid using too much disk space. PureMessage for UNIX includes a sample configuration file, logrotate.conf. This can be used to set the parameters for 'rotating' (i.e., archiving) the contents of the PureMessage log files.

The logrotate utility is a standard Linux component. It is also available for other UNIX platforms.

What to do

These notes provide a generic example of how to use logrotate. Adapt them to suit your environment and operating system. Refer to your operating system documentation for more information about logrotate. Log rotation is a standard maintenance task on UNIX systems, and is therefore outside the realm of PureMessage support.

Logrotate usually runs as a daily cron job in /etc/cron.daily. It can also be configured to run at set times, or when logs reach a specified size. Log rotation frequency depends on the volume of processed mail and reporting requirements (archived data from log files is no longer included in PureMessage's pre-defined reports).

Log rotation parameters are determined by the configuration of the /opt/pmx/etc/logrotate.conf configuration file, and the parameters configured for individual PureMessage log files. Parameters for individual log files are stored by default in the /opt/pmx/etc/logrotate.d directory, and include a configuration file for both the system log (pmx_log) and the message log (message_log), among others. The log configuration files (pmx_log, etc) are imported into the (logrotate.conf) configuration via the 'include /opt/pmx/etc/logrotate.d' statement in the logrotate.conf file.

The logrotate.d directory contains configuration files for the following logs:

  • access_log: Records all actions performed via the PureMessage Manager (controls clicked, pages requested, etc). Location: /opt/pmx/var/log/manager/.
  • activity_log: Records the activity of users and modules associated with the PureMessage Manager. Location: /opt/pmx/var/log/
  • autovac_log: Records the actions of the pmx-pg-autovac program, which is used to maintain the states of database tables in memory. Location: /opt/pmx/var/log/
  • blocklist_log: If MTA-level policy blocking is enabled, records the IP address of each message processed at the MTA level, along with the associated action. Location: /opt/pmx/var/log/
  • error_log: Records any errors related to the operation of the PureMessage Manager. Location: /opt/pmx/var/log/manager/
  • message_log: Records all messages that are processed by PureMessage. Contains both default and user-defined keys. This log is used primarily for reports. Location: /opt/pmx/var/log/
  • pg.log: Records, by default, any abnormal database activity. Can also be configured to log additional data. Location: /opt/pmx/postgres/
  • pmx_log: Records a variety of messages issued by pmx-milter, including debug, info, notice, warning, and error messages. Location: /opt/pmx/var/log/
  • scheduler_log: Records the failure of any scheduled job. Optionally, both successes and failures are logged, and failure notifications can be sent to the administrator's email account. Location: /opt/pmx/var/log/
  • vscan_log: If daemon-mode virus scanning is enabled, records all messages scanned for viruses. Location: /opt/pmx/var/log/

You can specify frequency and backlog settings globally in the logrotate.conf file, or individually for each log file in the sample pmx_log and message_log configuration files. The logrotate documentation for your operating system will include information about parameters.

Running logrotate as a scheduled job

The logrotate utility can be run as a scheduled job owned by the PureMessage user (by default, "pmx"). In the PureMessage Manager, create a new scheduled job. Enter /path/to/logrotate for the command. Add a description, and use the scroll boxes to configure how often the logs will be rotated.

Alternatively, from the command line, create a file named pmx-logrotate.conf in /opt/pmx/etc/scheduler.d, and add an <event logrotate> section. For example:

<event logrotate>
desc = "Rotate PureMessage Logs"
enabled = 1

type = exec
action = '/usr/local/sbin/logrotate /opt/pmx/etc/logrotate.conf'
<when>
s = 0
m = 0
h = 3
</when>
</event>

Specifying a state file

On some platforms, the default location of the state file for the system will be in a directory for which the PureMessage user has no rights. If so, specify an alternate state file, by inserting the following string in the logrotate command (before the specification of the .conf file):

-s /opt/pmx/var/log/logrotate.state

     
    If you need more information or guidance, then please contact technical support.

    Rate this article

    Very poor Excellent

    Comments