HP-UX Reference (11i v1 05/09) - 3 Library Functions N-Z (vol 7)

s
syslog(3C) syslog(3C)
EXAMPLES
who logs a message regarding some sort of unexpected and serious error:
syslog(LOG_ALERT, "who: internal error 23");
ftpd
uses openlog() to arrange to log its process ID, to log to the console if necessary, and to log in the
name of the daemon facility:
openlog("ftpd", LOG_PID|LOG_CONS, LOG_DAEMON);
Arrange to log messages only at levels LOG_ERR
and lower:
setlogmask(LOG_UPTO(LOG_ERR));
Typical usage of
syslog() to log a connection:
syslog(LOG_INFO, "Connection from host %s", CallingHost);
If the facility has not been set with
openlog(), it defaults to LOG_USER.
Explicitly set the facility for this message:
syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
WARNINGS
A call to syslog() has no effect unless the syslog daemon (syslogd(1M)) is running.
openlog() does
not copy and store the ident string internally; it stores only a character pointer. Therefore it is the respon-
sibility of the programmer to make sure that the ident argument points to the correct string until the log
file is closed.
AUTHOR
syslog() was developed by the University of California, Berkeley.
SEE ALSO
logger(1), syslogd(1M), thread_safety(5).
Section 3940 Hewlett-Packard Company 3 HP-UX 11i Version 1: September 2005