openlog() — Open the system control log

Standards

Standards / Extensions C or C++ Dependencies

XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <syslog.h>

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

General description

The openlog() function optionally opens a connection to the logging facility, and sets process attributes that affect subsequent calls to the syslog() function. The argument ident is a string that is prefixed to every message. logopt is a bit field indicating logging options. Current values of logopt are:
LOG_CONS
Write messages to the system console if they cannot be sent to the logging facility. This option is safe to use in processes that have no controlling terminal, since the syslog() function forks before opening the console.
LOG_NDELAY
Open the connection to the logging facility 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..
LOG_NOWAIT
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 the syslog() function may otherwise block waiting for a child whose exit status has already been collected.
LOG_ODELAY
Delay open until syslog() is called.
LOG_PID
Log the processID with each message. This is useful for identifying specific processes. In the message header, the processID is surrounded by square brackets. The code point values for the square brackets are taken from code page IBM-1047. The value for the left square bracket is 0xAD. The value for the right square bracket is 0xBD.
The facility argument encodes a default facility to be assigned to all messages that do not have an explicit facility already encoded. The initial default facility is as follows:
LOG_USER
Message generated by random processes. This is the default facility identifier if none is specified.

Returned value

openlog() returns no values.

No errors are defined.

Related information