syslog(3)

NAME
syslog, openlog, closelog -- control system log

SYNOPSIS
# include <syslog.h>

openlog(ident, logstat)
char *ident;

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

closelog()

DESCRIPTION
Syslog writes the message to the program syslog(8) The message is tagged with priority priority. The message looks like a printf(3) string except that %m is replaced by the current error message (collected from errno ). A trailing newline is added if needed. This message will be read by syslog(8) and output to the system console or files as appropriate.

If special processing is needed, openlog can be called to initialize the log file. Parameters are ident which is a string prepended to every message, and logstat a bit field indicating special status; current values are:

LOG_PID
    log the process id with each message: useful for identifying instantiations of daemons.

Openlog returns zero if it could create the socket. Otherwise, it arranges to write on /dev/console and returns -1. Calls to syslog can still proceed, but any message with priority under LogMask (normally LOG_CRIT) will be thrown away.

Closelog can be used to close the log socket.

EXAMPLES
syslog(LOG_SALERT, "who: internal error 23");

openlog("serverftp", LOG_PID);
syslog(LOG_INFO, "Connection from host %d", CallingHost);

SEE ALSO
syslog(8)