.\" Copyright (c) 1985, 1991 The Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)syslog.3 6.17 (Berkeley) 4/19/91
.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");