.\" Copyright (c) 1985 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)syslog.3 6.13 (Berkeley) %G%
syslog, openlog, closelog, setlogmask, vsyslog \- control system log
.B "openlog(ident, logopt, facility)
.B "syslog(priority, message, parameters ... )
.B "vsyslog(priority, message, args)
onto the system log maintained by
The message is tagged with
is replaced by the current error message (as referenced by
A trailing newline is added if needed.
An alternate form, in which the arguments have already been captured
using the variable-length argument facilities of
is available under the name
This message will be read by
and written to the system console, log files, or forwarded to
on another host as appropriate.
Priorities are encoded as a
The facility describes the part of the system
The level is selected from an ordered list:
A condition that should be corrected immediately,
such as a corrupted system database.
e.g., hard device errors.
Messages that contain information
normally of use only when debugging a program.
This is normally broadcast to all users.
Conditions that are not error conditions,
but should possibly be handled specially.
cannot pass the message to
it will attempt to write the message to the console (``/dev/console'')
if the LOG_CONS option is set (see below).
If special processing is needed,
can be called to initialize the log file.
is a string that is prepended to every message.
is a bit field indicating logging options.
If unable to send the message to
Normally the open is delayed
until the first message is logged.
Useful for programs that need to manage the
order in which file descriptors are allocated.
Write the message to stderr as well to the system log.
Log the process id with each message:
useful for identifying instantiations of daemons.
parameter encodes a default facility to be assigned to all messages
that do not have an explicit facility encoded:
The authorization system:
etc, that are not provided for explicitly by other facilities.
Messages generated by the kernel.
These cannot be generated by any user processes.
The line printer spooling system:
Messages generated internally by
Messages generated by random user processes.
This is the default facility identifier if none is specified.
Similarly for LOG_LOCAL1 through LOG_LOCAL7.
can be used to close the log file.
sets the log priority mask to
and returns the previous mask.
with a priority not set in
The mask for an individual priority
is calculated by the macro LOG_MASK(\fIpri\fP);
the mask for all priorities up to and including
is given by the macro LOG_UPTO(\fItoppri\fP).
The default allows all priorities to be logged.
syslog(LOG_ALERT, "who: internal error 23");
openlog("ftpd", LOG_PID, LOG_DAEMON);
setlogmask(LOG_UPTO(LOG_ERR));
syslog(LOG_INFO, "Connection from host %d", CallingHost);
syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");