Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ syslog(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

at(1)

crontab(1)

logger(1)

login(1)

lpr(1)

su(1)

cron(1M)

ftpd(1M)

getty(1M)

lpc(1M)

routed(1M)

syslogd(1M)

printf(3S)

syslog(5)

syslog(3C)                                                       syslog(3C)

NAME
     syslog, openlog, closelog, setlogmask - control system log

SYNOPSIS
     #include <syslog.h>

     void syslog(int level, const char *message, ... /* arguments */);

     void openlog(const char *ident, int logopt, int facility);

     void closelog(void);

     int setlogmask(int maskpri);

DESCRIPTION
     syslog passes message to syslogd, which logs it in an appropriate sys-
     tem log, writes it to the system console, forwards it to a list of
     users, or forwards it to the syslogd on another host over the network.
     The message looks like a printf string except that %m is replaced by
     the current error message (collected from errno). A trailing NEWLINE
     is added if needed.

     The message is tagged with a priority. Priorities are composed of
     facility and level. The facility describes the part of the system gen-
     erating 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, such as hard device errors.

     LOGERR        Errors.

     LOGWARNING    Warning messages.

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

     LOGINFO       Informational messages.

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

     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:





Page 1                       Reliant UNIX 5.44                Printed 11/98

syslog(3C)                                                       syslog(3C)

     LOGPID        Log the process ID with each message. This is useful
                    for identifying specific daemon processes (for daemons
                    that fork).

     LOGCONS       Write messages to the system console if they cannot be
                    sent to syslogd. This option is safe to use in daemon
                    processes that have no controlling terminal, since
                    syslog forks before opening the console.

     LOGNDELAY     Open the connection to syslogd immediately. Normally
                    the open is delayed until the first message is logged.
                    This is useful for programs that need to manage the
                    order in which file descriptors are allocated.

     LOGODELAY     Delay open until syslog() is called.

     LOGNOWAIT     Do not wait for child processes that have been forked
                    to log messages onto the console. This option should be
                    used by processes that enable notification of child
                    termination using SIGCHLD, since 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 already encoded:

     LOGKERN       Messages generated by the kernel. These cannot be gen-
                    erated 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, routed, etc.

     LOGAUTH       The authorization system: login, su, getty, etc.

     LOGLPR        The line printer spooling system: lpr, lpc, etc.

     LOGNEWS       Reserved for the USENET network news system.

     LOGUUCP       Reserved for the UUCP system; it does not currently use
                    syslog.

     LOGCRON       The cron/at facility; crontab, at, cron, etc.

     LOGLOCAL0-7   Reserved for local use.






Page 2                       Reliant UNIX 5.44                Printed 11/98

syslog(3C)                                                       syslog(3C)

     closelog can be used to close the log file.

     setlogmask sets the log priority mask to maskpri and returns the pre-
     vious mask. If the maskpri argument is 0, the current log mask is not
     modified. 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.

     A call to openlog is not required prior to calling setlogmask().

     Symbolic constants for use as values of the logopt, facility,
     priority, and maskpri arguments are defined in <syslog.h>.

EXAMPLES
     This call logs a message at priority LOGALERT:

          syslog(LOGALERT, "who: internal error 23");

     The FTP daemon, ftpd, would make this call to openlog to indicate that
     all messages it logs should have an identifying string of ftpd, should
     be treated by syslogd as other messages from system daemons are, and
     should include the process ID of the process logging the message:

          openlog("ftpd", LOGPID, LOGDAEMON);

     Then it would make the following call to setlogmask to indicate that
     messages at priorities from LOGEMERG through LOGERR should be
     logged, but that no messages at any other priority should be logged:

          setlogmask(LOGUPTO(LOGERR));

     Then, to log a message at priority LOGINFO, it would make the follow-
     ing call to syslog:

          syslog(LOGINFO, "Connection from host %d", CallingHost);

     A locally-written utility could use the following call to syslog to
     log a message at priority LOGINFO, to be treated by syslogd as other
     messages to the facility LOGLOCAL2 are treated:

          syslog(LOGINFO|LOGLOCAL2, "error: %m");

SEE ALSO
     at(1), crontab(1), logger(1), login(1), lpr(1), su(1), cron(1M),
     ftpd(1M), getty(1M), lpc(1M), routed(1M), syslogd(1M), printf(3S),
     syslog(5).






Page 3                       Reliant UNIX 5.44                Printed 11/98

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