Linux Logging Enhancements The logger Command

Forwarding the emergency messages to all logged−in users • The next section entries are presented in bold defines a conditional logging configuration. The m4 macro statement: ifdefLOGHOST,VAR1,VAR2 generates the output VAR1, or VAR2 depending on the status of the LOGHOST. For example: mail.debug ifdefLOGHOST, varlogsyslog, loghost specifies the file varlogsyslog as a logging destination for all mail messages if the system is the loghost, and if it is not, forwards messages to the remote loghost. Please note that the similar configuration entry for the authentication subsystem is commented out, and first should be activated uncommented. The last section, again the m4 preprocessor ifdef macro, has an output only if the local system is not the loghost; otherwise this part is ignored an empty ifdef output. If active, users processes are joined to all other processes specified in the first part of the configuration file some UNIX platforms distinguish users processes from all other processes. The bottom line in both cases is the same, because defined user processes are already covered by the first part of the configuration file user processes are not excluded from all processes. The second example HP−UX 10.20 is easier to understand and still quite adequate for many implementations; however, it provides only local logging: cat etcsyslog.conf Revision: 74.1 syslogd configuration file. See syslogd1M for information about the format of this file. mail.debug varadmsyslogmail.log .info;mail.none varadmsyslogsyslog.log .alert devconsole .alert root .emerg;user.none The last entry illustrates the meaning of the none level, which defines the following: Send system panic messages from all processes, except from users processes, to all logged−in users

9.2.2 Linux Logging Enhancements

Linux has introduced few improvements into logging subsystem. Linuxs logging subsystem supports sending of log messages to named pipes as well as to log files. But the main enhancements are configuration related. In the configuration file etcsyslog.conf few new configuration characters are introduced: space as a separating character • 211 to prefix a priority level and negate its meaning; it excludes this and higher priority levels from logging, specifying logging of only lower priority levels • To protect syslogd daemon from potential network intruders, new options −r and −h are introduced; they control daemon behavior toward accepting and forwarding log messages between hosts in the network. The daemon must be started appropriately if the corresponding network related logging is supposed. Although listed logging enhancements could be disputed, under certain circumstances their implementation could be handy.

9.2.3 The logger Command

UNIX provides the logger command, which is an extremely useful command to deal with system logging. The logger command sends logging messages to the syslogd daemon, and consequently provokes system logging. This means we can check from the command line at any time the syslogd daemon and its configuration. The command itself can also be a part of a user programscript to generate necessary operational logging messages. The logger command provides a method for adding one−line entries to the system log file from the command line. One or more message arguments can be entered with options on the command line, in which case each of them is logged immediately. If an optional message is not specified, either an optional file specified with the −f option or the standard input is added to the log. The format of the command is: logger [ −i ] [ −f file ] [ −p priority ] [ −t tag ] [ message ]... Where the available options and operands are: −f filename Use the contents of file filename as the message to log. −i Log the process ID of the logger process with each line. −p priority Enter the message with the specified priority specified selector entry; the message priority can be specified numerically, or as a facility.level pair. The default priority is user.notice. −t tag Mark each line added to the log with the specified tag. message The string arguments whose contents are concatenated together in the specified order, separated by the space a quoted message presents a single string argument.

9.2.4 Testing System Logging