void openlog (ID,
LogOption,
Facility)
const char *ID;
int LogOption, Facility;
void syslog (Priority, Value,... )
int Priority;
const char *Value;
int setlogmask(
MaskPriority)
int MaskPriority;
void bsdlog (Priority, Value,...)
int Priority;
const char *Value;
Attention: Do not use the syslog, openlog, closelog, or setlogmask subroutine in a multithreaded environment. See the multithread alternatives in the syslog_r, openlog_r, closelog_r, or setlogmask_r subroutine article. The syslog subroutine is not threadsafe; for threadsafe programs the syslog_r subroutine should be used instead.
The syslog subroutine writes messages onto the system log maintained by the syslogd command.
The message is similar to the printf fmt string, with the difference that %m is replaced by the current error message obtained from the errno global variable. A trailing new-line can be added to the message if needed.
Messages are read by the syslogd command and written to the system console or log file, or forwarded to the syslogd command on the appropriate host.
If special processing is required, the openlog subroutine can be used to initialize the log file.
Messages are tagged with codes indicating the type of Priority for each. A Priority is encoded as a Facility, which describes the part of the system generating the message, and as a level, which indicates the severity of the message.
If the syslog subroutine cannot pass the message to the syslogd command, it writes the message on the /dev/console file, provided the LOG_CONS option is set.
The closelog subroutine closes the log file.
The setlogmask subroutine uses the bit mask in the MaskPriority parameter to set the new log priority mask and returns the previous mask.
The LOG_MASK and LOG_UPTO macros in the sys/syslog.h file are used to create the priority mask. Calls to the syslog subroutine with a priority mask that does not allow logging of that particular level of message causes the subroutine to return without logging the message.
ID | Contains a string that is attached to the beginning of every message. The Facility parameter encodes a default facility from the previous list to be assigned to messages that do not have an explicit facility encoded. |
LogOption | Specifies a bit field that indicates logging options. The values of LogOption are: |
Facility | Specifies which of the following values generated the message: |
Priority | Specifies the part of the system generating the message, and as a level, indicates the severity of the message. The level of severity is selected from the following list: |
MaskPriority | Enables logging for the levels indicated by the bits in the mask that are set and disabled where the bits are not set. The default mask allows all priorities to be logged. |
Value | Specifies the values given in the Value parameters and follows the the same syntax as the printf subroutine Format parameter. |
syslog (LOG_ALERT, "who:internal error 23");
openlog ("ftpd", LOG_PID, LOG_DAEMON); setlogmask (LOG_UPTO (LOG_ERR)); syslog (LOG_INFO);
syslog (LOG_INFO | LOG_LOCAL2, "foobar error: %m");
These subroutines are part of the operating system.
The profil subroutine.
The cc command, prof command.
The syslogd daemon.
_end, _etext, or edata identifiers.
Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.