syslog.3   [plain text]


.\" 
.\" Copyright (c) 2000 Carnegie Mellon University.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 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. The name "Carnegie Mellon University" must not be used to
.\"    endorse or promote products derived from this software without
.\"    prior written permission. For permission or any other legal
.\"    details, please contact  
.\"      Office of Technology Transfer
.\"      Carnegie Mellon University
.\"      5000 Forbes Avenue
.\"      Pittsburgh, PA  15213-3890
.\"      (412) 268-4387, fax: (412) 268-7395
.\"      tech-transfer@andrew.cmu.edu
.\"
.\" 4. Redistributions of any form whatsoever must retain the following
.\"    acknowledgment:
.\"    "This product includes software developed by Computing Services
.\"     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
.\"
.\" CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
.\" THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
.\" AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
.\" FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" 
.\" $Revision: 1.2 $
.\" Copyright (c) 1985 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms are permitted provided
.\" that: (1) source distributions retain this entire copyright notice and
.\" comment, and (2) distributions including binaries display the following
.\" acknowledgement:  ``This product includes software developed by the
.\" University of California, Berkeley and its contributors'' in the
.\" documentation or other materials provided with the distribution and in
.\" all advertising materials mentioning features or use of this software.
.\" 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.\"	@(#)syslog.3	6.13 (Berkeley) 6/23/90
.\"
.TH SYSLOG 3 "June 23, 1990"
.UC 5
.SH NAME
syslog, openlog, closelog, setlogmask, vsyslog \- control system log
.SH SYNOPSIS
.B "#include <syslog.h>
.PP
.B "openlog(ident, logopt, facility)
.br
.B "char *ident;
.PP
.B "syslog(priority, message, parameters ... )
.br
.B "int priority;
.br
.B "char *message;
.PP
.B "#include <varargs.h>
.br
.B "vsyslog(priority, message, args)
.br
.B "int priority;
.br
.B "char *message;
.br
.B "va_list args;
.PP
.B "closelog()
.PP
.B "setlogmask(maskpri)
.SH DESCRIPTION
.I Syslog
arranges to write
.I message
onto the system log maintained by
.IR syslogd (8).
The message is tagged with
.IR priority .
The message looks like a
.IR printf (3)
string except that
.B %m
is replaced by the current error message (as referenced by
.IR errno ).
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
.IR varargs (3),
is available under the name
.IR vsyslog .
.PP
This message will be read by
.IR syslogd (8)
and written to the system console, log files, or forwarded to
.I syslogd
on another host as appropriate.
.PP
Priorities are encoded as a
.I facility
and a
.IR level .
The facility describes the part of the system
generating the message.
The level is selected from an ordered list:
.TP
LOG_ALERT
A condition that should be corrected immediately,
such as a corrupted system database.
.TP
LOG_CRIT
Critical conditions,
e.g., hard device errors.
.TP
LOG_DEBUG
Messages that contain information
normally of use only when debugging a program.
.TP
LOG_EMERG
A panic condition.
This is normally broadcast to all users.
.TP
LOG_ERR
Errors.
.TP
LOG_INFO
Informational messages.
.TP
LOG_NOTICE
Conditions that are not error conditions,
but should possibly be handled specially.
.TP
LOG_WARNING
Warning messages.
.PP
If
.I syslog
cannot pass the message to
.IR syslogd ,
it will attempt to write the message to the console (``/dev/console'')
if the LOG_CONS option is set (see below).
.PP
If special processing is needed,
.I openlog
can be called to initialize the log file.
The parameter
.I ident
is a string that is prepended to every message.
.I Logopt
is a bit field indicating logging options.
Current values for
.I logopt
are:
.TP
LOG_CONS
If unable to send the message to
.IR syslogd ,
write it to the console.
.TP
LOG_NDELAY 
Open the connection to
.I syslogd
immediately.
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.
.TP
LOG_PERROR
Write the message to stderr as well to the system log.
.TP
LOG_PID
Log the process id with each message:
useful for identifying instantiations of daemons.
.PP
The
.I facility
parameter encodes a default facility to be assigned to all messages
that do not have an explicit facility encoded:
.TP
LOG_AUTH
The authorization system:
.IR login (1),
.IR su (1),
.IR getty (8),
etc.
.TP
LOG_CRON
The clock daemon.
.TP
LOG_DAEMON
System daemons, such as
.IR ftpd (8),
.IR routed (8),
etc, that are not provided for explicitly by other facilities.
.TP
LOG_KERN
Messages generated by the kernel.
These cannot be generated by any user processes.
.TP
LOG_LPR
The line printer spooling system:
.IR lpr (1),
.IR lpc (8),
.IR lpd (8),
etc.
.TP
LOG_MAIL
The mail system.
.TP
LOG_NEWS
The network news system.
.TP
LOG_SYSLOG
Messages generated internally by
.IR syslogd (8).
.TP
LOG_USER
Messages generated by random user processes.
This is the default facility identifier if none is specified.
.TP
LOG_UUCP
The uucp system.
.TP
LOG_LOCAL0
Reserved for local use.
Similarly for LOG_LOCAL1 through LOG_LOCAL7.
.PP
.I Closelog
can be used to close the log file.
.PP
.I Setlogmask
sets the log priority mask to
.I maskpri
and returns the previous mask.
Calls to
.I syslog
with a priority not set in
.I maskpri
are rejected.
The mask for an individual priority
.I pri
is calculated by the macro LOG_MASK(\fIpri\fP);
the mask for all priorities up to and including
.I toppri
is given by the macro LOG_UPTO(\fItoppri\fP).
The default allows all priorities to be logged.
.SH EXAMPLES
.nf
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");
.fi
.SH "SEE ALSO"
logger(1),
syslogd(8)