.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)syslog.3 6.5 (Berkeley) %G%
syslog, openlog, closelog, setlogmask \- control system log
.B "openlog(ident, logopt, facility)
.B "syslog(priority, message, parameters ... )
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.
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:
.IP LOG_EMERG \w'LOG_WARNING'u+3
This is normally broadcast to all users.
.IP LOG_ALERT \w'LOG_WARNING'u+3
A condition that should be corrected immediately,
such as a corrupted system database.
.IP LOG_CRIT \w'LOG_WARNING'u+3
e.g., hard device errors.
.IP LOG_ERR \w'LOG_WARNING'u+3
.IP LOG_WARNING \w'LOG_WARNING'u+3
.IP LOG_NOTICE \w'LOG_WARNING'u+3
Conditions that are not error conditions,
but should possibly be handled specially.
.IP LOG_INFO \w'LOG_WARNING'u+3
.IP LOG_DEBUG \w'LOG_WARNING'u+3
Messages that contain information
normally of use only when debugging a program.
cannot pass the message to
and the message is priority LOG_ERR or higher,
it attempts to write the message on
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.
.IP LOG_PID \w'LOG_WARNING'u+3
log the process id with each message:
useful for identifying instantiations of daemons.
.IP LOG_CONS \w'LOG_WARNING'u+3
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.
.IP LOG_NDELAY \w'LOG_WARNING'u+3
Opening the connection 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.
parameter is encodes a default facility to be assigned to all messages
that do not have an explicit facility encoded:
.IP LOG_KERN \w'LOG_WARNING'u+3
Messages generated by the kernel.
These cannot be generated by any user processes.
.IP LOG_USER \w'LOG_WARNING'u+3
Messages generated by random user processes.
This is the default if none is specified.
.IP LOG_MAIL \w'LOG_WARNING'u+3
.IP LOG_DAEMON \w'LOG_WARNING'u+3
.IP LOG_AUTH \w'LOG_WARNING'u+3
The authorization system:
.IP LOG_LPR \w'LOG_WARNING'u+3
The line printer spooling system:
.IP LOG_LOCAL0 \w'LOG_WARNING'u+3
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 lower than
The default allows all priorities to be logged.
syslog(LOG_ALERT, "who: internal error 23");
openlog("ftpd", LOG_PID, LOG_DAEMON);
syslog(LOG_INFO, "Connection from host %d", CallingHost);
syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");