Go to the first, previous, next, last section, table of contents.

Logging commands

A log can be kept of actions taken by a filter file. This facility is normally available in conventional configurations, but there are some situations where it might not be. Also, the system administrator may choose to disable it. Check your local information if in doubt.

Logging takes place while the filter file is being interpreted. It does not queue up for later like the delivery commands. The reason for this is so that a log file need be opened only once for several write operations. There are two commands, neither of which constitutes a significant delivery. The first defines a file to which logging output is subsequently written:

     logfile <file name>
e.g. logfile $home/filter.log

The file name may optionally be followed by a mode for the file, which is used if the file has to be created. For example,

     logfile $home/filter.log 0644

The number is interpreted as octal, even if it does not begin with a zero. The default for the mode is 600. It is suggested that the `logfile' command normally appear as the first command in a filter file. Once `logfile' has been obeyed, the `logwrite' command can be used to write to the log file:

     logwrite "<some text string>"
e.g. logwrite "$tod_log $message_id processed"

It is possible to have more than one `logfile' command, to specify writing to different log files in different circumstances. Writing takes place at the end of the file, and a newline character is added to the end of each string if there isn't one already there. Newlines can be put in the middle of the string by using the `\n' escape sequence. Lines from simultaneous deliveries may get interleaved in the file, as there is no interlocking, so you should plan your logging with this in mind. However, data should not get lost.

In earlier versions of Exim the `logwrite' command was called `log', and this name remains available for backwards compatibility. However, it is not possible to use the name `log' as a command name following a `mail' command, because it will be interpreted as the `log' option of that command.

Go to the first, previous, next, last section, table of contents.