.\" Copyright (c) 1985 The Regents of the University of California.
.\" Redistribution and use in source and binary forms are permitted
.\" provided that the above copyright notice and this paragraph are
.\" duplicated in all such forms and that any documentation,
.\" advertising materials, and other materials related to such
.\" distribution and use acknowledge that the software was developed
.\" by the University of California, Berkeley. The name of the
.\" University may not be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\" @(#)syslog.3 6.11 (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 (collected from
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:
This is normally broadcast to all users.
A condition that should be corrected immediately,
such as a corrupted system database.
e.g., hard device errors.
Conditions that are not error conditions,
but should possibly be handled specially.
Messages that contain information
normally of use only when debugging a program.
cannot pass the message to
it will attempt to write the message on
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.
Log the process id with each message:
useful for identifying instantiations of daemons.
Write the message to stderr as well to the system log.
Force writing messages to the console if unable to send it to
This option is safe to use in daemon processes that have no controlling
will fork before opening the console.
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.
Don't wait for children forked to log messages on the console.
This option should be used by processes that enable notification
of child termination via SIGCHLD, as
may otherwise block waiting for a child whose exit status has already
parameter encodes a default facility to be assigned to all messages
that do not have an explicit facility encoded:
Messages generated by the kernel.
These cannot be generated by any user processes.
Messages generated by random user processes.
This is the default facility identifier if none is specified.
etc, that are not provided for explicitly by other facilities.
The authorization system:
Messages generated internally by
The line printer spooling system:
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");