next up previous

Syslog and Log Files

This contains links to information used in the lectures.

Logging Policies

Location of Log Files


Very inconsistent over vendors and daemons. Note this can be a problem, if one you are unaware of grows indefinitely.
The log files may be specified: To locate log files read startup scripts to see if logging is on and, possibly, what file is used. In some cases there is a dedicated file, in other cases syslog is used - the location of logging is usually given in /etc/syslog.conf.
Some general points:

Do NOT manage


Do not manage /usr/adm/lastlog or /etc/utmp.
/usr/adm/lastlog records user's last login and is on sparse file format which will grow alarmingly if copied.
utmp attempts to keep a record of logged in users.

Vendor Specific Locations

HP-UX 9.XX

On HP-UX 9.XX log files are in /usr/adm. The files nettl.LOG00 and nettl.LOG01 are network control and statistics files. The diag directory contains files in binary format, the secure directory the secure password files, and acct the fiscal accounting files/directories.

SunOS

On SunOS most log files are in /var/adm. The secure directory the secure password files, and acct the fiscal accounting files/directories.

HP-UX 10.XX

On HP-UX 10.XX most log files are in /var/adm.

SYSLOG - the system event logger

Syslog used by many vendor to log information generated by kernel and system utilities. Syslog is intended to Syslog allows: Syslog consists of: syslogd is in /etc on HP-UX, /usr/etc on SunOS and in /usr/sbin on some systems. logger is in /usr/bin on HP-UX and /usr/ucb on SunOS. The syslog routines are part of the standard C library.

syslogd

syslogd is started at boot time and runs continuously. Programs write log entries using the library routines to the special file /dev/log. In HP-UX, syslogd collects messages from the UNIX domain socket /dev/log.un, an Internet domain socket specified in /etc/services, and from the named pipe /dev/log. By default, local programs calling syslog() send log messages to the UNIX domain socket (see syslog(3C)). If UNIX domain sockets are not configured on the system, they write to the named pipe instead. If INET domain sockets are not configured, syslogd does not receive messages forwarded from other hosts, nor does it forward messages. The syslogd command reads and logs messages into a set of files described by the configuration file /etc/syslog.conf.

syslogd creates the file syslog.pid containing a single line with its process ID. This can be used to kill or reconfigure syslogd. It is in /var/run/ on HP-UX 10.XX, /etc on HP-UX 9.XX and SunOS.

To kill syslogd, send it a terminate signal:


           kill `cat /var/run/syslog.pid`

To make syslogd, re-read its configuration file, send it a HANGUP signal:


           kill -HUP `cat /var/run/syslog.pid`

Do not try to compress or rotate log files that syslog has open. Some vendors supply a skeletal rotation script - another rotz is on the CD.

Configuring syslogd

/etc/syslog.conf is a text file. Each message is one line. A message can contain a priority code, marked by a number in angle braces at the beginning of the line. Priorities are defined in the header file . Lines in the configuration file consist of a selector to determine the message priorities to which the line applies and an action. The action field is separated from the selector by one or more tabs.
selector<TAB>action
For example:
mail.info	/var/log/maillog
Note that separators must be <TAB>s not blanks. Note also that cutting and pasting using X converts <TAB>s to blanks thus introducing invisible errors which may be difficult to detect. Selectors are semicolon separated lists of priority specifiers. Each priority has a facility indicating the subsystem that generated the message, a dot, and a level indicating the severity of the message. Symbolic names can be used. An asterisk selects all facilities. All messages of the specified level or higher (greater severity) are selected. More than one facility can be selected, using commas to separate them. For example:
           *.emerg;mail,daemon.crit
selects all facilities at the emerg level and the mail and daemon facilities at the crit level. The additional facility mark has a message at priority LOG_INFO sent to it every 20 minutes (this can be changed with the -m flag). This can be useful when trying to determine when a machine has crashed at night. The mark facility is not enabled by a facility field containing an asterisk. The level none can be used to disable a particular facility. For example,
           *.debug;mail.none
selects all messages except mail messages. In general, selectors are ORed together. However selectors with a level of none excludes the listed facilties regardless of other selectors. The known facilities and levels recognized by syslogd are those listed in syslog(3C) converted to lowercase without the leading LOG_.

The second part of each line describes where the message is to be logged if this line is selected. There are four forms:

Blank lines and lines beginning with a # character are ignored.

For example, the configuration file:

 kern,mark.debug   /dev/console
 mail.debug        /var/adm/syslog/mail.log
 *.info;mail.none  /var/adm/syslog/syslog.log
 *.alert /dev/console
 *.alert root,eric,kridle
 *.emerg *
 *.emerg @admin
logs all kernel messages and 20 minute marks onto the system console, all mail system messages to /var/adm/syslog/mail.log, and all messages at info and above, except mail messages, to the file /var/adm/syslog/syslog.log. Messages at alert and above are logged to the console and to the users root, eric, and kridle if they are logged in. emerg messages are written to all logged-in users' terminals, and forwarded to the host admin. Only a superuser can invoke syslogd.

Designing a Logging Scheme

Software that uses Syslog

See Table 12.5 in book.

Debugging syslog

Using syslog in programs

See book for examples.



next up previous


Paul A. Farrell
Thu Mar 7 15:10:34 EST 1996