MTA transaction logging

From Messaging Server Technical Reference Wiki
Jump to: navigation, search


The MTA's optional logging of message traffic is enabled via the logging channel option. Enabling logging causes the MTA to write an entry to a mail.log* file each time a message passes through an MTA channel. Such log entries can be useful if you wish to get statistics on how many messages are passing through the MTA (or through particular channels), or when investigating other questions such as whether and when a message was sent or delivered.

If you are only interested in gathering statistics on the number of messages passing through a few particular MTA channels, then you may wish to enable the logging channel option on just those MTA channels of main interest. But more generally, many sites prefer to enable logging on all MTA channels; in particular, if you are trying to track down problems, the first step in diagnosing some problems is to notice that messages are not going to the channel you expected or intended, and having logging enabled for all channels can help you spot such issues.

In addition to the basic information always provided when logging is enabled, additional, optional informational fields may also be logged in the mail.log files, controlled via various log_* MTA options. Particularly likely to be of interest are the log_message_id, log_envelope_id, log_filename, log_connection, log_process, and log_username options.

  • Enabling log_message_id allows correlation of which entries relate to which message.
  • Enabling log_envelope_id allows easier correlation of which entries from mail.log files from different systems correspond to the same message at the SMTP level.
  • Enabling log_filename makes it easier to immediately spot how many times delivery of a particular message file has been retried, and can be useful in understanding when the MTA does or does not split a message to multiple recipients into separate message file copies on disk.
  • Enabling log_connection causes the MTA to log TCP/IP connections, as well as message traffic, to the mail.log files by default; alternatively, the separate_connection_log option may be used to specify that connection log entries instead be written to connection.log files.
  • When using log_connection to cause generation of TCP/IP connection entries, additionally enabling log_process allows correlation of which connection entries correspond to which message entries.
  • log_username is mostly of interest in the case of users who authenticate their message submission using the SMTP AUTH command; in such cases, log_username causes logging of the user identity (prefixed with an asterisk character if the identity was established by authentication). As of the 8.0 release, the log_username option can also be used to log the primary mail address associated with the authenticated identity and in the case of "U" connection log entries, the authentication mechanism used.

The mail.log and connection.log entries may optionally be duplicated to syslog via the log_messages_syslog and log_connections_syslog options.


See also: