Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ syslog(SLIB) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

logger(TC)

syslogd(ADMN)


 syslog(SLIB)                   6 January 1993                   syslog(SLIB)


 Name

    syslog, openlog, setlogmask, vsyslog - control system log

 Syntax


    #include  <syslog.h>

    openlog(ident, logopt, facility)
    char *ident;

    syslog(priority, message, parameters  . . .  )
    int priority;
    char *message;

    #include  <varargs.h>
    vsyslog(priority, message, args)
    int priority;
    char *message;
    va_list args;

    closelog()

    setlogmask(maskpri)


 Description

    syslog arranges to write message onto the system log maintained by
    syslogd(ADMN).  The message is tagged with priority.  The message looks
    like a printf(S) string except that %m is replaced by the current error
    message (collected from 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 varargs(S), is available
    under the name vsyslog.

    This message will be read by syslogd(ADMN) and written to the system con-
    sole, log files, or forwarded to syslogd on another host as appropriate.

    Priorities are encoded as a facility and a level.  The facility describes
    the part of the system generating the message.  The level is selected
    from an ordered list:

    LOGEMERG   A panic condition.  This is normally broadcast to all users.

    LOGALERT   A condition that should be corrected immediately, such as a
                corrupted system database.

    LOGCRIT    Critical conditions, for example, hard device errors.

    LOGERR     Errors.

    LOGWARNING Warning messages.

    LOGNOTICE  Conditions that are not error conditions, but may require
                special handling.

    LOGINFO    Informational messages.

    LOGDEBUG   Messages that contain information normally of use only when
                debugging a program.

    If syslog cannot pass the message to syslogd, it will attempt to write
    the message on /dev/console if the LOGCONS option is set (see below).

    If special processing is needed, openlog can be called to initialize the
    log file.  The parameter ident is a string that is prepended to every
    message.  logopt is a bit field indicating logging options.  Current
    values for logopt are:

    LOGPID     Log the process id with each message.  This is useful for
                identifying instantiations of daemons.

    LOGCONS    Force writing messages to the console if unable to send it to
                syslogd.  This option is safe to use in daemon processes that
                have no controlling terminal since syslog will fork before
                opening the console.

    LOGNDELAY  Open the connection to 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.

    LOGNOWAIT  Do not wait for forked children to log messages on the con-
                sole.  This option should be used by processes that enable
                notification of child termination via SIGCHLD, as syslog may
                otherwise block waiting for a child whose exit status has
                already been collected.

    The facility parameter encodes a default facility to be assigned to all
    messages that do not have an explicit facility encoded:

    LOGKERN    Messages generated by the kernel.  These cannot be generated
                by any user processes.

    LOGUSER    Messages generated by random user processes.  This is the
                default facility identifier if none is specified.

    LOGMAIL    The mail system.

    LOGDAEMON  System daemons, such as ftpd(ADMN), routed(ADMN), etc.

    LOGLPR     The line printer spooling system:  lpd(ADMN).

    LOGLOCAL0  Reserved for local use.  This is also true for LOGLOCAL1
                through LOGLOCAL7.

    closelog can be used to close the log file.

    setlogmask sets the log priority mask to maskpri and returns the previous
    mask.  Calls to syslog with a priority not set in maskpri are rejected.
    The mask for an individual priority pri is calculated by the macro
    LOGMASK(pri); the mask for all priorities up to and including toppri is
    given by the macro LOGUPTO(toppri).  The default allows all priorities
    to be logged.

 Examples


       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");


 See also

    logger(TC) and syslogd(ADMN).


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026