HP-UX Reference (11i v1 00/12) - 3 Library Functions N-Z (vol 7)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/nan.3m
________________________________________________________________
___ ___
s
syslog(3C) syslog(3C)
LOG_NOWAIT Do not wait for children forked to log messages on the console.
This option should be used by processes that enable notification
of child termination via SIGCLD, because syslog() might
otherwise block, waiting for a child whose exit status has already
been collected.
facility encodes a default facility to be assigned to all messages written subsequently by
syslog() with no explicit facility encoded.
LOG_KERN Messages generated by the kernel. These cannot be generated
by any user processes.
LOG_USER Messages generated by random user processes. This is the
default facility identifier if none is specified.
LOG_MAIL The mail system.
LOG_DAEMON System daemons, such as inetd(1M), ftpd(1M), etc.
LOG_AUTH The authorization system: login(1), su(1), getty(1M), etc.
LOG_LPR The line printer spooling system: lp(1), lpsched(1M), etc.
LOG_LOCAL0 Reserved for local use. Similarly for LOG_LOCAL1
through
LOG_LOCAL7.
closelog() closes the log file.
setlogmask()
sets the log priority mask to maskpri and returns the previous mask. Calls to syslog()
with a priority not set in maskpri are rejected. The mask for an individual priority pri is
calculated by the macro
LOG_MASK(pri); the mask for all priorities up to and including
toppri is given by the macro LOG_UPTO(toppri). By default, all priorities are logged.
APPLICATION USAGE
The interfaces syslog(), openlog(), closelog() and setlogmask() are thread-safe. These
interfaces are not async-cancel-safe. A cancellation point may occur when a thread is executing
sys-
log()
, openlog() or closelog() .
ERRORS
syslog fails if any of the following conditions are encountered:
[EAGAIN] The named pipe /dev/log is blocked for writing.
[ENOENT] The named pipe
/dev/log bold) could not be opened successfully.
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
Section 3−−906 − 2 − HP-UX Release 11i: December 2000
___
___