For example, designating
LOG_CRON results in the submission of subsequent messages to the cron log, whereas
designating LOG_USER results in the transmission of messages to the messages file.
Unless PHP is being used as a command-line interpreter, you??™ll likely want to set
this to LOG_USER. It??™s common to use LOG_CRON when executing PHP scripts from a
crontab. See the syslog documentation for more information about this matter.
Closing the Logging Connection
The closelog() function closes the connection opened by openlog(). Its prototype
follows:
int closelog(void)
Sending a Message to the Logging Destination
The syslog() function is responsible for sending a custom message to the syslog. Its
prototype follows:
int syslog(int priority, string message)
Table 8-2. Logging Options
Option Description
LOG_CONS If an error occurs when writing to the syslog, send output to the system
console.
LOG_NDELAY Immediately open the connection to the syslog.
LOG_ODELAY Do not open the connection until the first message has been submitted
for logging. This is the default.
LOG_PERROR Output the logged message to both the syslog and standard error.
LOG_PID Accompany each message with the process ID (PID).
220 CHAPTER 8 ?– ERRO R AND EXCEPTION HANDL ING
The first parameter, priority, specifies the syslog priority level, presented in order of
severity here:
LOG_EMERG: A serious system problem, likely signaling a crash
LOG_ALERT: A condition that must be immediately resolved to avert jeopardizing
system integrity
LOG_CRIT: A critical error, which could render a service unusable but does not
necessarily place the system in danger
LOG_ERR: A general error
LOG_WARNING: A general warning
LOG_NOTICE: A normal but notable condition
LOG_INFO: A general informational message
LOG_DEBUG: Information that is typically only relevant when debugging an application
The second parameter, message, specifies the text of the message that you??™d like to
log.
Pages:
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298