Open System Services Programmer's Guide

Table 32 OSS Logging Facilities (continued)
DescriptionMessage StringFacility
Messages generated by a line printer subsystem.LPRLOG_LPR
Messages generated by a mail subsystem.MAILLOG_MAIL
Messages generated by a network news subsystem.NEWSLOG_NEWS
Messages generated by a syslogd demon.SYSLOGLOG_SYSLOG
Messages generated by user processes. This is the default
value.
USERLOG_USER
Messages generated by a UNIX-to-UNIX copy program
(UUCP) subsystem.
UUCPLOG_UUCP
identity Parameter
The identity parameter enables you to specify an event subject string to appear in the OSS log
message. The default subject string is “syslog.
logopt Parameter
The logopt parameter enables you to specify logging options. You can specify any set of options.
To specify more than one option, separate the options with the OR operator (|), as in the following
example:
openlog(LOG_CONS | LOG_PID);
The default value of logopt is LOG_ODELAY, which waits until the first message is logged before
opening a collector. Table 33 (page 240) lists the logging options.
Table 33 OSS Logging Options
DescriptionOption
Sends the event message to the local primary collector, $0, if the message cannot be
sent to the collector specified by the EMS_COLLECTOR environment variable
LOG_CONS
Opens the connection to the collector process immediatelyLOG_NDELAY
Has no effectLOG_NOWAIT
Waits until the first message is logged before opening the connection to the collector
process
LOG_ODELAY
Has no effectLOG_PERROR
Includes the OSS process ID of the calling process in each event messageLOG_PID
If you specify both LOG_NDELAY and LOG_ODELAY, LOG_NDELAY takes effect.
NOTE: Do not use the LOG_PID option on a Guardian process. If you do, the syslog() function
will call the openlog() function and fail with Guardian trap 5, because Guardian processes
have no OSS process ID.
Logging a Message
You call the syslog() function whenever you want to log a message from your program. For
suggestions about the kinds of events and messages to log, refer to the EMS Manual.
You can use the formatting codes that printf() recognizes in a syslog() call. Example 55
shows a code fragment with a call to syslog() using these codes.
240 Using Logging Mechanisms