syslog() — Send a message to the 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 syslog(int priority, const char *message, … /* argument */);

General description

The syslog() function sends a message to an implementation-specific logging facility, which loads it in an appropriate system log, writes it to the system console, forwards it to a list of users, or forwards it to the logging facility on another host over the network. The logged message includes a message header and a message body. The message header consists of a facility indicator, a severity indicator, a timestamp, a tag string, and optionally the process ID. The process ID 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 message body is generated from the message and following arguments in the same manner as if these were arguments to the printf() function, except that occurrences of %m in the format string pointed to by the message argument are replaced by the error message string associated with the current value of errno. A trailing newline character is added if needed.

Note: If the total length of the format string and the parameters is greater than 4096 bytes, then the results are undefined.
Values of the priority argument are formed by ORing together a severity level values and an option facility value. If no facility value is specified, the current default facility value is used. Possible values of severity level include:
LOG_ALERT
A condition that should be corrected immediately, such as a corrupted system database.
LOG_CRIT
Critical conditions, such as hard device errors.
LOG_DEBUG
Messages that contain information normally of use only when debugging a program.
LOG_EMERG
A Panic condition. This is normally broadcast to all processes.
LOG_ERR
Errors.
LOG_INFO
Informational messages.
LOG_NOTICE
Conditions that are not error conditions, but that may require special handling.
LOG_WARNING
Warning messages.
The facility indicates the application or system component generating the message. Possible facility values include:
LOG_USER
Message generated by random processes. This is the default facility identifier if none is specified.
LOG_LOCAL0
Reserved for local use.
LOG_LOCAL1
Reserved for local use.
LOG_LOCAL2
Reserved for local use.
LOG_LOCAL3
Reserved for local use.
LOG_LOCAL4
Reserved for local use.
LOG_LOCAL5
Reserved for local use.
LOG_LOCAL6
Reserved for local use.
LOG_LOCAL7
Reserved for local use.

Returned value

syslog() returns no values.

Related information