大网数据广告活动
PHP 语言与运行手册

openlog · Open connection to system logger

· 52CE 我爱测

openlog() opens a connection to the system logger for a program.

openlog

(PHP 4, PHP 5, PHP 7, PHP 8)

openlog — Open connection to system logger

说明

function openlog(string $prefix, int $flags, int $facility): true

openlog() opens a connection to the system logger for a program.

The use of openlog() is optional. If it has not been called, the connection is opened by the first message that is logged. When that message comes from syslog(), then in PHP 8.1 to 8.3, up to PHP 8.4.27 and up to PHP 8.5.12 the prefix and the facility are left to the system (the prefix is usually the name of the program, and php on Windows), and the syslog.ident and syslog.facility INI settings are not used. When it comes from error_log or mail.log set to syslog, those settings are used.

参数

prefix

The string prefix is added to each message.

flags

Bitmask of the following constants:

facility

The facility argument is used to specify what type of program is logging the message. This lets the configuration file specify that messages from different facilities will be handled differently. Must be one of the following constants:

注意:

This parameter is ignored on Windows.

返回值

总是返回 true。

更新日志

版本 说明
8.2.0 The function now always returns true. Previously it returned false on failure.

参见

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。