SYSLOG(3) — SUBROUTINES
NAME
syslog, openlog, closelog − control system log
SYNOPSIS
#include <syslog.h>
openlog(ident, logstat)
char ∗ident;
syslog(priority, message, parameters ... )
char ∗message;
closelog()
DESCRIPTION
Syslog arranges to write the message onto the system log maintained by syslog(8). The message is tagged with priority. The message looks like a printf(3S) string except that %m is replaced by the current error message (collected from errno). A trailing newline is added if needed. This message will be read by syslog(8) and output to the system console or files as appropriate.
If special processing is needed, openlog can be called to initialize the log file. Parameters are ident which is prepended to every message, and logstat which is a bit field indicating special status; current values are:
LOG_PIDlog the process id with each message: useful for identifying instantiations of daemons.
Openlog returns zero on success. If syslog cannot send datagrams to syslog(8), then it writes on /dev/console instead. If /dev/console cannot be written, standard error is used. In either case, it returns -1.
Closelog can be used to close the log file. It is automatically closed on a successful exec system call (see execve(2)).
EXAMPLES
syslog(LOG_SALERT, "who: internal error 23");
openlog("serverftp", LOG_PID);
syslog(LOG_INFO, "Connection from host %d", CallingHost);
SEE ALSO
Sun Release 2.0 — Last change: 15 March 1984