SYSLOG(3)               NetBSD Library Functions Manual              SYSLOG(3)

     syslog, syslog_r, vsyslog, vsyslog_r, syslogp, syslogp_r, vsyslogp,
     vsyslogp_r, openlog, openlog_r, closelog, closelog_r, setlogmask,
     setlogmask_r -- control system log

     Standard C Library (libc, -lc)

     #include <syslog.h>



     syslogp(int priority, const char *msgid, const char *sdfmt,
         const char *message, ...);

     syslogp_r(int priority, struct syslog_data *data, const char *msgid,
         const char *sdfmt, const char *message, ...);


         struct syslog_data *data);


     closelog_r(struct syslog_data *data);

     setlogmask(int maskpri);

     setlogmask_r(int maskpri, struct syslog_data *data);

     #include <stdarg.h>


         va_list args);

     vsyslogp(int priority, const char *msgid, const char *sdfmt,
         const char *message, va_list args);

     vsyslogp_r(int priority, struct syslog_data *data, const char *msgid,
         const char *sdfmt, const char *message, va_list args);



     The syslog_r() function is a multithread-safe version of the syslog()
     store information.  This parameter must be initialized before syslog_r()
     syslog_data structure and the SYSLOG_DATA_INIT constant are defined as:

           struct syslog_data {
                   int             log_file;
                   int             connected;
                   int             opened;
                   int             log_stat;
                   const char     *log_tag;
                   int             log_fac;
                   int             log_mask;

           #define SYSLOG_DATA_INIT { \
               .log_file = -1, \
               .log_fac = LOG_USER, \
               .log_mask = 0xff, \

     The structure is composed of the following elements:

           log_file   contains the file descriptor of the file where the mes-
                      sage is logged

           connected  indicates if connect has been done

           opened     indicates if openlog_r() has been called

           log_stat   status bits, set by openlog_r()

           log_tag    string to tag the entry with

           log_fac    facility code

           log_mask   mask of priorities to be logged

     already been captured using the variable-length argument facilities of

     The syslogp() variants take additional arguments which correspond to new
     fields in the syslog-protocol message format.  All three arguments are
     evaluated as printf(3) format strings and any of them can be NULL.  This
     enables applications to use message IDs, structured data, and UTF-8
     encoded content in messages.

     The message is tagged with priority.  Priorities are encoded as a
     erating the message.  The level is selected from the following ordered
     (high to low) list:

     LOG_EMERG     A panic condition.  This is normally broadcast to all

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

     LOG_CRIT      Critical conditions, e.g., hard device errors.

     LOG_ERR       Errors.

     LOG_WARNING   Warning messages.

     LOG_NOTICE    Conditions that are not error conditions, but should possi-
                   bly be handled specially.

     LOG_INFO      Informational messages.

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

     version of the vsyslog() function described above.

     The openlog() function provides for more specialized processing of the
     of the following values:

                   attempt to write the message to the console

     LOG_NDELAY    Open the connection to syslogd(8) 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.

     LOG_NLOG      Stops syslog from writing to the system log.  Only useful
                   with LOG_PERROR.

     LOG_PERROR    Write the message to standard error output as well to the
                   system log.

                   ing instantiations of daemons.  (This PID is placed within
                   brackets between the ident and the message.)

     LOG_PTRIM     Trim anything syslog added to the message before writing to
                   standard error output.

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


                   selected individuals.

     LOG_CRON      The cron daemon: cron(8).

                   for explicitly by other facilities.

     LOG_FTP       The file transfer protocol daemon: ftpd(8).

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


     LOG_MAIL      The mail system.

     LOG_NEWS      The network news system.

     LOG_SYSLOG    Messages generated internally by syslogd(8).

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

     LOG_UUCP      The uucp system.

     LOG_LOCAL0    Reserved for local use.  Similarly for LOG_LOCAL1 through

     function.  It takes an additional pointer to a syslog_data structure.


     safe way and takes an additional pointer to a syslog_data structure.

     allows all priorities to be logged.

     The setlogmask_r() function is the multithread-safe version of

     syslog_r(), vsyslog(), vsyslog_r(), syslogp(), syslogp_r(), vsyslogp(),
     and vsyslogp_r() return no value.

     log mask level.






           syslogp(LOG_INFO|LOG_LOCAL2, NULL, NULL, "foobar error: %m");

           syslogp(LOG_INFO, "ID%d", "[meta language=\"en-US\"]",
                   "event: %s", 42, EventDescription);

     For the multithread-safe functions:

           struct syslog_data sdata = SYSLOG_DATA_INIT;


     logger(1), syslogd(8)

     The BSD syslog Protocol, RFC, 3164, August 2001.

     The syslog Protocol, Internet-Draft, draft-ietf-syslog-protocol-23,
     September 2007.

     The async-signal-safe functions appeared in NetBSD 4.0.  The syslog-pro-
     tocol functions appeared in NetBSD 5.0.

     conversion specifiers for later interpolation by syslog().

     Always be sure to use the proper secure idiom:

           syslog(priority, "%s", string);

     With syslogp() the caller is responsible to use the right formatting for
     the message fields.  A msgid must only contain up to 32 ASCII characters.
     A sdfmt has strict rules for parenthesis and character quoting.  If the
     msgfmt contains UTF-8 characters, then it has to start with a Byte Order

NetBSD 8.0                      March 22, 2017                      NetBSD 8.0




©1994 Man-cgi 1.15, Panagiotis Christias
©1996-2019 Modified for NetBSD by Kimmo Suominen