|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Write a message to the system log
#include <syslog.h> void syslog( int priority, const char * message, ...)
- The priority of the message; see “Message levels,” below.
- The message that you want to write. This message is identical to a printf()-format string, except that %m is replaced by the current error message (as denoted by the global variable errno). A trailing newline is added if none is present.
The formatting characters that you use in the message determine any additional arguments.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The syslog() function writes message to the system message logger. The message is then written to the system console, log files, and logged-in users, or forwarded to other machines as appropriate. (See the syslogd command.)
The vsyslog() function is an alternate form in which the arguments have already been captured using the variable-length argument facilities of <stdarg.h>.
The message is tagged with priority. Priorities are encoded as a facility and a level. The facility describes the part of the system generating the message. The level is selected from the following list (ordered from high to low):
- A panic condition. This is normally broadcast to all users.
- A condition that should be corrected immediately, such as a corrupted system database.
- Critical conditions (for example, hard device errors).
- General errors.
- Warning messages.
- Conditions that aren't error conditions, but should possibly be specially handled.
- Informational messages.
- Messages that contain information normally of use only when debugging a program.
syslog(LOG_ALERT, "who: internal error 23"); openlog("ftpd", LOG_PID, LOG_DAEMON); setlogmask(LOG_UPTO(LOG_ERR)); syslog(LOG_INFO, "Connection from host %d", CallingHost); syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");