Recipe 1.10 Logging sendmail

Problem

Debugging a problem in the sendmail configuration may require more detailed information than sendmail logs by default.

Solution

Use the LogLevel option, either on the sendmail command line using the -O flag or in the sendmail configuration using the confLOG_LEVEL define, to increase the LogLevel above the default level of 9.

If the confLOG_LEVEL define is used, rebuild and reinstall sendmail.cf , and restart sendmail, as described in Recipe 1.8.

Discussion

sendmail logs messages through syslog using the mail facility. Where the messages are logged is determined by the syslog.conf file. A grep of syslog.conf shows where the sendmail messages are logged on our sample Linux system:

 $ grep mail /etc/syslog.conf # Log anything (except mail) of level info or higher. *.info;mail.none;authpriv.none;cron.none            /var/log/messages # Log all the mail messages in one place. mail.*                                              /var/log/maillog 

Disregarding the comments, there are two lines in this particular syslog.conf file that mention the mail facility. The first line has a wildcard character in the facility field, meaning that it applies to every syslog facility. At first glance, you might think this applies to sendmail messages until you notice mail.none , which means that no messages from the mail facility will be logged in /var/log/messages . /var/log/maillog is the place to look for sendmail log entries on this sample Linux system. The mail.* entry means that, no matter what the level, all messages from the mail facility are logged in /var/log/maillog . Of course, this syslog.conf file is specific to our sample system. Your file might look different and, even if it looks exactly like this one, you can change it in anyway that you wish. You completely control where sendmail logs messages.

The syslog.conf file controls where sendmail messages are logged. The sendmail LogLevel option controls what is logged. The default sendmail LogLevel is 9, which is roughly equivalent to the syslog level info . Increasing the value of LogLevel increases the amount of data that sendmail logs. The meaningful LogLevel values are:


Log a limited number of severe problems, such as failing to find the system's hostname or qualified domain name .


1

Log serious system failures using syslog crit and alert levels.


2

Log networking failures at crit level.


3

Log connection timeouts, malformed addresses, and forward and include errors using notice and error syslog levels.


4

Log connection rejections, bad qf filenames, and outdated aliases databases using info and notice levels.


5

Log envelope cloning, and log an entry for each message received. These log entries are made at the syslog info level.


6

Log a record of each message returned to the original sender, and log incoming SMTP VRFY , EXPN , and ETRN commands using the info level.


7

Log delivery failures at the info level.


8

Log successful deliveries and alias database rebuilds at the syslog notice level.


9

Log mail deferred because of lack of system resources at the info level.


10

Log inbound SMTP connections and MILTER connects and replies. Log each database lookup. Log AUTH and STARTTLS errors. All of these messages are logged at info level. Also log TLS errors at syslog warning level.


11

Log end of processing, and log NIS errors. Log both types of messages at info level.


12

Log outbound SMTP connections at info level.


13

Log questionable file security, such as world-writable files and bad user shells .


14

Log connection refusals. Log additional STARTTLS information. Log both types of messages at info level.


15

Log all incoming SMTP commands at info level.


16-98

Log debugging information at debug level. This data is mostly suitable for code developers.

Setting LogLevel causes all levels below the specified number to also be logged. Thus the default LogLevel of 9 also logs all of the messages described for levels 1 through 8. Each LogLevel adds more detail while continuing to log the messages of the lower LogLevel settings.

LogLevel can be set inside the sendmail configuration using the confLOG_LEVEL define. For example:

 define(`confLOG_Level', `14') 

However, it is often only necessary to increase LogLevel for a short time or for a single test run. This can be done by defining LogLevel on the sendmail command line using the -O argument. Here is an example:

 # sendmail -O LogLevel=14 -bs -Am 

This example runs sendmail from the command line. The -Am argument, which does not apply to sendmail versions before 8.12, ensures that sendmail runs as an MTA ”this argument is the opposite of the -Ac option discussed earlier in this chapter. The -bs argument allows you to manually input the SMTP commands in a manner similar to the telnet tests used in the previous recipe. The -O argument allows you to set the LogLevel from the command line. A command such as this might be used to log the effect of specific SMTP interactions.

Both techniques for setting LogLevel work well. The technique you use depends on the circumstances and your preference.

See Also

The sendmail book covers logging in Section 14.3 and LogLevel in Section 24.9.56.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net