.\" Copyright (c) 1985 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)syslog.3 6.14 (Berkeley) %G%
syslog, vsyslog, openlog, closelog, setlogmask \- control system log
syslog(int priority, char *message, [, arg ] ... );
vsyslog(int priority, char *message, va_list args);
openlog(char *ident, int logopt, int facility);
to the system message logger.
The message will then be 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 ``%m'' is replaced by the current error
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
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:
cannot pass the message to
it will attempt to write the message to the console (``/dev/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:
The authorization system:
The same as LOG_AUTH, 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.
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(pri);''
the mask for all priorities up to and including
is given by the macro ``LOG_UPTO(toppri);''.
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");
return 0 upon successful completion.
Otherwise, -1 is returned and
is set to indicate the error.
always returns the previous log mask level, never returning
may fail and set errno for any of the errors specified for the library
may fail and set errno for any of the errors specified for the library
may fail and set errno for any of the errors specified for the library