Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ syslog(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf, fprintf, sprintf, NLprintf, NLfprintf, NLsprintf, wsprintf



SYSLOG(3,L)                 AIX Technical Reference                 SYSLOG(3,L)



-------------------------------------------------------------------------------
syslog, openlog, closelog, setlogmask



PURPOSE

Makes a system log entry.

LIBRARY

Standard C Library (libc.a)

SYNTAX

#include <syslog.h>




   int syslog (priority, message [, val, ... ])   int closelog ( )
   int priority;
   char *message;                                 int setlogmask(maskpri)
                                                  int maskpri;
   int openlog (ident, logopt, facility)
   char *ident;
   int logopt, facility;



DESCRIPTION

The syslog subroutine writes messages onto the system log maintained by the
syslogd daemon.  The message string message is similar to the printf fmt
string, with the difference that "%m" is replaced by the current error message
obtained from errno.  A trailing new line can be added to the message if
needed.  The val parameters are the same as the val parameters of the printf
subroutine.  Each log message has a time stamp prepended to it.

Messages are read by the syslogd and written to the system console or log file,
or forwarded to the syslogd on the appropriate host.

Messages are tagged with codes indicating the type of priority for each.  A
priority is encoded as a facility, which describes the part of the system
generating the message, and as a level, which indicates the severity of the
message.

The facility that generated the message is one of the following:

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




Processed November 7, 1990        SYSLOG(3,L)                                 1





SYSLOG(3,L)                 AIX Technical Reference                 SYSLOG(3,L)



LOG_USER       Messages generated by user processes.  This is the default
               facility when none is specified.

LOG_MAIL       The mail system.

LOG_DAEMON     System daemons.

LOG_AUTH       The authorization system: login and su, for example.

LOG_LPR        The line printer spooling system.

LOG_LOCAL0     Reserved for local use.
-through-
LOG_LOCAL7

The level of severity is one of the following:

LOG_EMERG    A panic condition reported to all users.

LOG_ALERT    A condition that should be corrected immediately; for example, a
             corrupted database.

LOG_CRIT     Critical conditions; for example, hard device errors.

LOG_ERR      Errors.

LOG_WARNING  Warning messages.

LOG_NOTICE   Not an error condition, but a condition requiring special
             handling.

LOG_INFO     General information messages.

LOG_DEBUG    Messages containing information useful to debug a program.

If syslog cannot pass the message to syslogd, it writes the message on
/dev/console, provided the LOG_CONS option is set.

If special processing is required, the openlog subroutine can be used to
initialize the log file.  The ident parameter contains a string that is
attached to the beginning of every message.  The default ident is syslog.  The
facility parameter encodes a default facility from the previous list to be
assigned to messages that do not have an explicit facility encoded.

The logopt parameter is a bit field that indicates logging options.  The values
of logopt include:

LOG_PID      Log the process ID with each message.  This option is useful for
             identifying daemons.






Processed November 7, 1990        SYSLOG(3,L)                                 2





SYSLOG(3,L)                 AIX Technical Reference                 SYSLOG(3,L)



LOG_CONS     Send messages to the console if unable to send them to syslogd.
             This option is useful in daemon processes that have no controlling
             terminal.

LOG_NDELAY   Open the connection to syslogd immediately, instead of when the
             first message is logged.  This option is useful for programs that
             need to manage the order in which file descriptors are allocated.

LOG_NOWAIT   Log messages to the console without waiting for forked child
             processes.  Use this option for processes that enable notification
             of child process termination through SIGCHLD; otherwise, syslog
             may block, waiting for a child process whose exit status has
             already been collected.

The closelog subroutine closes the log file.

The setlogmask subroutine uses the bit mask in maskpri to set the new log
priority mask and returns the previous mask.  Logging is enabled for the levels
indicated by the bits in the mask that are set and disabled where the bits are
not set.  The default mask allows all priorities to be logged.

The LOG_MASK and LOG_UPTO macros in the /usr/include/sys/syslog.h file are used
to create the priority mask.  Calls to syslog with a priority mask that does
not allow logging of that particular level of message cause the subroutine to
return without logging the message.

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

RELATED INFORMATION

In this book:  "printf, fprintf, sprintf, NLprintf, NLfprintf, NLsprintf,
wsprintf."

The discussion of syslogd in AIX Operating System Commands Reference.













Processed November 7, 1990        SYSLOG(3,L)                                 3



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