The symbols referred to in this section are declared in the file syslog.h.
syslog
submits a message to the Syslog facility. It does this by writing to the Unix domain socket/dev/log
.
syslog
submits the message with the facility and priority indicated by facility_priority. The macroLOG_MAKEPRI
generates a facility/priority from a facility and a priority, as in the following example:LOG_MAKEPRI(LOG_USER, LOG_WARNING)The possible values for the facility code are (macros):
LOG_USER
- A miscellaneous user process
LOG_MAIL
LOG_DAEMON
- A miscellaneous system daemon
LOG_AUTH
- Security (authorization)
LOG_SYSLOG
- Syslog
LOG_LPR
- Central printer
LOG_NEWS
- Network news (e.g. Usenet)
LOG_UUCP
- UUCP
LOG_CRON
- Cron and At
LOG_AUTHPRIV
- Private security (authorization)
LOG_FTP
- Ftp server
LOG_LOCAL0
- Locally defined
LOG_LOCAL1
- Locally defined
LOG_LOCAL2
- Locally defined
LOG_LOCAL3
- Locally defined
LOG_LOCAL4
- Locally defined
LOG_LOCAL5
- Locally defined
LOG_LOCAL6
- Locally defined
LOG_LOCAL7
- Locally defined
Results are undefined if the facility code is anything else.
NB:
syslog
recognizes one other facility code: that of the kernel. But you can't specify that facility code with these functions. If you try, it looks the same tosyslog
as if you are requesting the default facility. But you wouldn't want to anyway, because any program that uses the GNU C Library is not the kernel.You can use just a priority code as facility_priority. In that case,
syslog
assumes the default facility established when the Syslog connection was opened. See Syslog Example.The possible values for the priority code are (macros):
LOG_EMERG
- The message says the system is unusable.
LOG_ALERT
- Action on the message must be taken immediately.
LOG_CRIT
- The message states a critical condition.
LOG_ERR
- The message describes an error.
LOG_WARNING
- The message is a warning.
LOG_NOTICE
- The message describes a normal but important event.
LOG_INFO
- The message is purely informational.
LOG_DEBUG
- The message is only for debugging purposes.
Results are undefined if the priority code is anything else.
If the process does not presently have a Syslog connection open (i.e., it did not call
openlog
),syslog
implicitly opens the connection the same asopenlog
would, with the following defaults for information that would otherwise be included in anopenlog
call: The default identification string is the program name. The default default facility isLOG_USER
. The default for all the connection options in options is as if those bits were off.syslog
leaves the Syslog connection open.If the dev/log socket is not open and connected,
syslog
opens and connects it, the same asopenlog
with theLOG_NDELAY
option would.
syslog
leaves /dev/log open and connected unless its attempt to send the message failed, in which casesyslog
closes it (with the hope that a future implicit open will restore the Syslog connection to a usable state).Example:
#include <syslog.h> syslog (LOG_MAKEPRI(LOG_LOCAL1, LOG_ERROR), "Unable to make network connection to %s. Error=%m", host);