.\" Copyright (c) 1985, 1991 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)syslog.3 6.17 (Berkeley) %G%
.Fn syslog "int priority" "const char *message" "..."
.Fn vsyslog "int priority" "const char *message" "va_list args"
.Fn openlog "const char *ident" "int logopt" "int facility"
.Fn setlogmask "int maskpri"
to the system message logger.
The message is then written to the system console, log files,
logged-in users, or forwarded to other machines as appropriate. (See
The message is identical to a
format string, except that
is replaced by the current error
message. (As denoted by the global variable
A trailing newline is added if none is present.
is an alternate form in which the arguments have already been captured
using the variable-length argument facilities of
The message is tagged with
Priorities are encoded as a
The facility describes the part of the system
The level is selected from the following
.Bl -tag -width LOG_AUTHPRIV
This is normally broadcast to all users.
A condition that should be corrected immediately, such as a corrupted
Critical conditions, 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.
provides for more specialized processing of the messages sent
is a string that will be prepended to every message.
is a bit field specifying logging options, which is formed by
one or more of the following values:
.Bl -tag -width LOG_AUTHPRIV
cannot pass the message to
it will attempt to write the message to 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.
Write the message to standard error output 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:
.Bl -tag -width LOG_AUTHPRIV
The authorization system:
but logged to a file readable only by
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.
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
the mask for all priorities up to and including
The default allows all priorities to be logged.
always returns the previous log mask level.
.Bd -literal -offset indent -compact
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");