PHP Manual

PHP function openlog()

11. 09. 2019

Obsah článku

Available in `PHP 4`, `PHP 5`, `PHP 7`

Opens a connection to the system logger.

Parameters

Parameter Data type Default value Note
$ident string not Identifier (of type string) to be added to the message.
$option int not The $option argument is used to indicate which logging options will be used when generating the log message. Details below.
$facility int not The $facility argument is used to indicate what type of program logs the message. This allows you to specify (in your machine's syslog configuration) how messages coming from different devices will be handled. Details below.

$option

The $option argument is used to indicate which logging options will be used when generating a log message.

Possible values:

Constant Description
LOG_CONS If an error occurs when writing to the logger (or sending data), it prints a message to the system console.
LOG_NDELAY Immediately opens a connection to the logger.
LOG_ODELAY (default) Delay between writing individual messages. It is mainly used when writing the first message to the logger.
LOG_PERROR Print the logged error also as a standard PHP error.
LOG_PID Include the PID number in the message.

You can select one or more options.

If you use multiple options, use the OR logical notation between constants.

For example: LOG_CONS | LOG_NDELAY | LOG_PID.

$facility

The $facility argument is used to specify what type of program is logging the message. This allows you to specify (in your machine's syslog configuration) how messages coming from different devices will be handled.

Constant Description
LOG_AUTH Security or authorization messages. If this constant is not defined on your system, use LOG_AUTHPRIV.
LOG_AUTHPRIV Security or authorization messages. Private Message.
LOG_CRON Hourly retries (cron).
LOG_DAEMON System deamon that waits for events.
LOG_KERN Messages from the operating system kernel.
LOG_LOCAL0 ... LOG_LOCAL7 Reserved for use on a specific local device or server. Not available on Windows.
LOG_LPR Subsystem for line dump.
LOG_MAIL Subsystem for handling e-mail and mail server.
LOG_NEWS Subsystem for handling news and messages (USENET).
LOG_SYSLOG Messages generated internally by syslogd (may contain system messages from the operating system).
LOG_USER Default messages defined by the user or a specific extension. They are not system messages.
LOG_UUCP Subsystem UUCP.

Return values

bool - returns true on success, false on error.

Other resources

[Official openlog function documentation](Official PHP.net documentation)

Jan Barášek   Více o autorovi

Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.

Rád vám pomůžu:

Související články

1.

V jiných jazycích

2.
Status:
All systems normal.
2024