logger(C)


logger -- make entries in the system log

Syntax

logger [ -i ] [ -f file ] [ -p priority ] [ -s ] [ -t tag ] message ...

Description

logger immediately logs one or more messages given on the command line; it provides a command line interface to the syslog(SLIB-osr5) system call. The system logger daemon, syslogd(ADM), writes the messages to a default system log file, or to a log file, host machine, or user(s) defined in the configuration file /etc/syslog.conf. The format of this file is described on the syslogd(ADM) manual page.

If a message is not specified, the contents of the file specified using the -f option are logged; otherwise, the standard input is logged until EOF is encountered.

logger understands the following options:


-f file
Log the contents of the specified file.

-i
Log the process ID of the logger process with each line.

-p priority
Enter the message with the specified priority. The priority may be specified numerically (priorities are defined in /usr/include/sys/syslog.h), or in the form facility.level as described on the syslogd(ADM) manual page. The default priority is user.notice.

-s
Log the message to stderr.

-t tag
Mark every line in the log with the specified tag.

Exit values

logger returns the following values:

0
successful completion

>0
an error occurred

Examples

Log messages as priority level info in the local3 facility:

logger  -p  local3.info  messages

Write a message defined in /tmp/msg to /usr/var/syslog (assuming that this is defined as the default log file for local0 facility messages in /etc/syslog.conf), and tag each line with the string ``OPER'':

logger  -p  local0.notice  -t  OPER  -f  /tmp/msg

A message can be tagged with a numeric or symbolic priority within angled brackets:

logger  "<local0.debug> foobar failed"

When a numeric priority is specified, this is expressed as:

logger  "<135> foobar failed"

The numeric priority of 135 is calculated as follows:

  1. /usr/include/sys/syslog.h defines the value of the facility portion of the priority (local0) as LOG_LOCAL0 as ``16<<3'' (that is, 16 * 8 or 128)

  2. /usr/include/sys/syslog.h defines the value of the level portion of the priority (debug) as LOG_DEBUG as 7

  3. 128 and 7 when summed yield the priority 135
The string ``%m'' within a message is replaced by the current error message (corresponding the global error number, errno):
   logger  "<local0.debug>  foobar failed with reason: %m"

Files


/usr/include/sys/syslog.h
symbolic and numeric definitions of facility and priority level settings

/usr/adm/messages
log for error messages

/usr/adm/hwconfig
log for device initialization messages

/etc/syslog.conf
configuration file for syslogd which specifies destination of different priority messages

/usr/adm/syslog
default log for info and debug priority level messages

See also

error(HW), perror(S-osr5), syslogd(ADM), syslog(SLIB-osr5)

Standards conformance

logger is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005