Home Menu

syslog

Generate a system log message

Syntax

syslog ( int $priority , string $message ) : bool

Parameters

priority

priority is a combination of the facility and the level.

Constant (descending order) Description
LOG_EMERG system is unusable
LOG_ALERT action must be taken immediately
LOG_CRIT critical conditions
LOG_ERR error conditions
LOG_WARNING warning conditions
LOG_NOTICE normal, but significant, condition
LOG_INFO informational message
LOG_DEBUG debug-level message
message

The message to send, except that the two characters %m will be replaced by the error message string (strerror) corresponding to the present value of errno.

Return

Returns TRUE on success or FALSE on failure.

Examples

<?

// open syslog, include the process ID and send the log to standard error, and use a user defined logging mechanism

$ident = "myScriptLog";
$option = LOG_PID | LOG_PERROR;
$facility = LOG_LOCAL0;

openlog($ident, $option, $facility);

    if (authorized_client()) {
        // do something
    } else {
        // unauthorized client, log attempt
        $access = date("Y/m/d H:i:s");
        $priority = LOG_WARNING;
        $message = "unauthorized client: $access {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})";
        syslog($priority, $message);
    }

closelog();

?>

			
			

		

Internal

closelog

openlog

External

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms