Previous   Next   Contents       (Exim 4.00 Specification)

44. Log files

Exim writes three different logs, referred to as the main log, the reject log, and the panic log:

Every log line starts with a timestamp, in the format shown in this example:

  2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed by QUIT

44.1. Where the logs are written

The logs may be written to local files, or to syslog, or both. However, it should be noted that many syslog implementations use UDP as a transport, and are therefore unreliable in the sense that messages are not guaranteed to arrive at the loghost, nor is the ordering of messages necessarily maintained. It has also been reported that on large log files (tens of megabytes) you may need to tweak syslog to prevent it syncing the file with each write - on Linux this has been seen to make syslog take 90% plus of CPU time.

The destination for Exim's logs is configured by setting LOG_FILE_PATH in Local/Makefile or by setting log_file_path in the run time configuration. This latter string is expanded, so it can contain, for example, references to the host name:

  log_file_path = /var/log/$primary_hostname/exim_%slog

It is generally advisable, however, to set the string in Local/Makefile rather than at run time, because then the setting is available right from the start of Exim's execution. Otherwise, if there's something it wants to log before it has read the configuration file (for example, an error in the configuration file) it will not use the path you want, and may not be able to log at all.

The value of LOG_FILE_PATH or log_file_path is a colon-separated list, currently limited to at most two items. This is one option where the facility for changing a list separator may not be used. The list must always be colon-separated. If an item in the list is ``syslog'' then syslog is used; otherwise the item must either be an absolute path, containing %s at the point where ``main'', ``reject'', or ``panic'' is to be inserted, or be empty, implying the use of the default path, which is log/%slog in Exim's spool directory. The default path is used if nothing is specified. Here are some examples of possible settings:

  LOG_FILE_PATH=syslog  syslog only
  LOG_FILE_PATH=:syslog  syslog and default path
  LOG_FILE_PATH=syslog : /usr/log/exim_%s  syslog and specified path
  LOG_FILE_PATH=/usr/log/exim_%s  specified path only

If there are more than two paths in the list, the first is used and a panic error is logged.

44.2. Logging to local files

Some operating systems provide centralized and standardised methods for cycling log files. For those that do not, a utility script called exicyclog is provided (see section 45.4). This renames and compresses the main and reject logs each time it is called. The maximum number of old logs to keep can be set. It is suggested this script is run as a daily cron job.

An Exim delivery process opens the main log when it first needs to write to it, and it keeps the file open in case subsequent entries are required - for example, if a number of different deliveries are being done for the same message. However, remote SMTP deliveries can take a long time, and this means that the file may be kept open long after it is renamed if exicyclog or something similar is being used to rename log files on a regular basis. To ensure that a switch of log files is noticed as soon as possible, Exim calls stat() on the main log's name before reusing an open file, and if the file does not exist, or its inode has changed, the old file is closed and Exim tries to open the main log from scratch. Thus, an old log file may remain open for quite some time, but no Exim processes should write to it once it has been renamed.

44.3. Logging to syslog

The use of syslog does not change what Exim logs or the format of its messages, except in one respect. If syslog_timestamp is set false, the timestamps on Exim's log lines are omitted when these lines are sent to syslog. Apart from that, the same strings are written to syslog as to log files. The syslog ``facility'' is set to LOG_MAIL, and the program name to ``exim''. On systems that permit it (all except ULTRIX) the LOG_PID flag is set so that the syslog() call adds the pid as well as the time and host name to each line. The three log streams are mapped onto syslog priorities as follows:

Many log lines are written to both mainlog and rejectlog, so there will be duplicates if these are routed by syslog to the same place.

Exim's log lines can sometimes be very long, and some of its rejectlog entries contain multiple lines when headers are included. To cope with both these cases, entries written to syslog are split into separate syslog() calls at each internal newline, and also after a maximum of 1000 characters. To make it easy to re-assemble them later, each component of a split entry starts with a string of the form ``[<n>/<m>]'' or ``[<n>\<m>]'' where <n> is the component number and <m> is the total number of components in the entry. The / delimiter is used when the line was split because it was too long; if it was split because of an internal newline, the \ delimiter is used. For example, supposing the length limit to be 70 instead of 1000, the following would be the result of a typical rejection message to mainlog (LOG_INFO), each line in addition being preceded by the time, host name, and pid as added by syslog:

  [1/3] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
  [2/3] syntax error in 'From' header when scanning for sender: missing or ma
  [3/3] lformed local part in "<>" (envelope sender is <ph10@cam.example>)

The same error might cause the following lines to be written to ``rejectlog'' (LOG_NOTICE):

  [1/14] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
  [2/14] syntax error in 'From' header when scanning for sender: missing or ma
  [3\14] lformed local part in "<>" (envelope sender is <ph10@cam.example>)
  [4\14] Recipients: ph10@some.domain.cam.example
  [5\14] P Received: from [127.0.0.1] (ident=ph10)
  [6\14] by xxxxx.cam.example with smtp (Exim 4.00)
  [7\14] id 16RdAL-0006pc-00
  [8\14] for ph10@cam.example; Mon, 16 Sep 2002 16:09:43 +0100
  [9\14] F From: <>
  [10\14] Subject: this is a test header
  [11\14] X-something: this is another header
  [12\14] I Message-Id: <E16RdAL-0006pc-00@xxxxx.cam.example>
  [13\14] B Bcc:
  [14/14] Date: Mon, 16 Sep 2002 16:09:43 +0100

Log lines that are neither too long nor contain newlines are written to syslog without modification.

If only syslog is being used, the Exim monitor is unable to provide a log tail display, unless syslog is routing mainlog to a file on the local host and the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor where it is.

44.4. Log line flags

One line is written to the main log for each message received, and for each successful, unsuccessful, and delayed delivery. These lines can readily be picked out by the distinctive two-character flags that immediately follow the timestamp. The flags are:

  <=  message arrival
  =>  normal message delivery
  ->  additional address in same delivery
  *>  delivery suppressed by -N
  **  delivery failed; address bounced
  ==  delivery deferred; temporary problem

44.5. Logging message reception

The format of the single-line entry in the main log that is written for every message received is shown in the basic example below, which is split over several lines in order to fit it on the page:

  2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@dwarf.fict.example
   H=mailer.fict.example [192.168.123.123] U=exim
   P=smtp S=5678 id=<incoming message id>

The address immediately following ``<='' is the envelope sender address. A bounce message is shown with the sender address ``<>'', and if it is locally generated, this is followed by an item of the form

  R=<message id>

which is a reference to the message that caused the bounce to be sent.

For messages from other hosts, the H and U fields identify the remote host and record the RFC 1413 identity of the user that sent the message, if one was received. The number given in square brackets is the IP address of the sending host. If there is just a single host name in the H field, as above, it has been verified to correspond to the IP address (see the host_lookup option). If the name is in parentheses, it was the name quoted by the remote host in the SMTP HELO or EHLO command, and has not been verified. If verification yields a different name to that given for HELO or EHLO, the verified name appears first, followed by the HELO or EHLO name in parentheses.

Misconfigured hosts (and mail forgers) sometimes put an IP address, with or without brackets, in the HELO or EHLO command, leading to entries in the log containing text like these examples:

  H=(10.21.32.43) [192.168.8.34]
  H=([10.21.32.43]) [192.168.8.34]

This can be confusing. Only the final address in square brackets can be relied on.

For locally generated messages (that is, messages not received over TCP/IP), the H field is omitted, and the U field contains the login name of the caller of Exim.

For all messages, the P field specifies the protocol used to receive the message. This is set to ``asmtp'' for messages received from hosts which have authenticated themselves using the SMTP AUTH command. In this case there is an additional item A= followed by the name of the authenticator that was used. If an authenticated identification was set up by the authenticator's server_set_id option, this is logged too, separated by a colon from the authenticator name.

The id field records the existing message id, if present. The size of the received message is given by the S field. When the message is delivered, headers may get removed or added, so that the size of delivered copies of the message may not correspond with this value (and indeed may be different to each other).

The log_selector option can be used to request the logging of additional data when a message is received. See section 44.13 below.

44.6. Logging deliveries

The format of the single-line entry in the main log that is written for every delivery is shown in one of the examples below, for local and remote deliveries, respectively. Each example has been split into two lines in order to fit it on the page:

  2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv <marv@hitch.fict.example>
   R=localuser T=local_delivery
  2002-10-31 09:00:10 16ZCW1-0005MB-00 => monk@holistic.fict.example
   R=dnslookup T=remote_smtp H=holistic.fict.example [192.168.234.234]

For ordinary local deliveries, the original address is given in angle brackets after the final delivery address, which might be a pipe or a file. If intermediate address(es) exist between the original and the final address, the last of these is given in parentheses after the final address. The R and T fields record the router and transport that were used to process the address.

If a shadow transport was run after a successful local delivery, the log line for the successful delivery has an item added on the end, of the form

  ST=<shadow transport name>

If the shadow transport did not succeed, the error message is put in parentheses afterwards.

When more than one address is included in a single delivery (for example, two SMTP RCPT commands in one transaction) the second and subsequent addresses are flagged with ``->'' instead of ``=>''. When two or more messages are delivered down a single SMTP connection, an asterisk follows the IP address in the log lines for the second and subsequent messages.

The generation of a reply message by a filter file gets logged as a ``delivery'' to the addressee, preceded by ``>''.

The log_selector option can be used to request the logging of additional data when a message is received. See section 44.13 below.

44.7. Discarded deliveries

When a message is discarded as a result of the command ``seen finish'' being obeyed in a filter file which generates no deliveries, a log entry of the form

  2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
   <low.club@bridge.example> R=userforward

is written, to record why no deliveries are logged. When a message is discarded because it is aliased to ``:blackhole:'' the log line is like this:

  1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
    <hole@nowhere.example> R=blackhole_router

44.8. Deferred deliveries

When a delivery is deferred, a line of the following form is logged:

  2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
   R=dnslookup T=smtp defer (146): Connection refused

In the case of remote deliveries, the error is the one that was given for the last IP address that was tried. Details of individual SMTP failures are also written to the log, so the above line would be preceded by something like

  2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
   mail1.endrest.example [192.168.239.239]: Connection refused

When a deferred address is skipped because its retry time has not been reached, a message is written to the log, but this can be suppressed by setting an appropriate value in log_selector.

44.9. Delivery failures

If a delivery fails, a line of the following form is logged:

  2002-12-19 16:20:23 16aiQz-0002Q5-00 ** jim@trek99.example
   <jimtrek99.example>: unknown mail domain

44.10. Fake deliveries

If a delivery does not actually take place because the -N option has been used to suppress it, a normal delivery line is written to the log, except that ``=>'' is replaced by ``*>''.

44.11. Completion

A line of the form

  2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed

is written to the main log when a message is about to be removed from the spool at the end of its processing.

44.12. Other log entries

Various other types of log entry are written from time to time. Most should be self-explanatory. Among the more common are:

44.13. Reducing or increasing what is logged

By setting the log_selector global option, you can disable some of Exim's default logging, or you can request additional logging. The value of log_selector is made up of names preceded by plus or minus characters. For example:

  log_selector = +arguments -retry_defer

The list of optional log items is in the following table, with the default selection marked by asterisks:

   address_rewrite  address rewriting
   all_parents  all parents in => lines
   arguments  command line arguments
  *connection_reject  connection rejections
  *delay_delivery  immediate delivery delayed (message queued)
   delivery_size  add S=nnn to => lines
  *dnslist_defer  defers of DNS list (aka RBL) lookups
  *etrn  ETRN commands
   incoming_interface  incoming interface on <= lines
   incoming_port  incoming port on <= lines
  *lost_incoming_connection  as it says (includes timeouts)
  *queue_run  start and end queue runs
   received_recipients  recipients on <= lines
   received_sender  sender on <= lines
  *retry_defer  ``retry time not reached''
   sender_on_delivery  add sender to => lines
  *size_reject  rejection because too big
  *skip_delivery  ``message is frozen'', ``spool file is locked''
   smtp_confirmation  SMTP confirmation on <= lines
   smtp_connection  SMTP connections
   smtp_protocol_error  SMTP protocol errors
   smtp_syntax_error  SMTP syntax errors
   subject  contents of Subject: on <= lines
  *tls_cipher  TLS cipher on <= lines
   tls_peerdn  TLS peer DN on <= lines
  
   all  all of the above

More details on each of these items follows:

44.14. Message log

In addition to the general log files, Exim writes a log file for each message that it handles. The names of these per-message logs are the message ids, and they are kept in the msglog sub-directory of the spool directory. Each message log contains copies of the log lines that apply to the message. This makes it easier to inspect the status of an individual message without having to search the main log. A message log is deleted when processing of the message is complete, unless preserve_message_logs is set, but this should be used only with great care because they can fill up your disc very quickly.


Previous  Next  Contents       (Exim 4.00 Specification)