syslog Generate a system log message
发表日期:2021-07-01 08:56:42 | 来源: | | 浏览(902) 分类:网络 函数
syslog
(PHP 4, PHP 5, PHP 7, PHP 8)
syslog — Generate a system log message
说明
$priority
, string $message
): boolsyslog() generates a log message that will be distributed by the system logger.
For information on setting up a user defined log handler, see the syslog.conf (5) Unix manual page. More information on the syslog facilities and option can be found in the man pages for syslog (3) on Unix machines.
参数
-
priority
-
priority
is a combination of the facility and the level. Possible values are:syslog() Priorities (in descending order) Constant 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.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 Using syslog()
<?php // open syslog, include the process ID and also send// the log to standard error, and use a user defined// logging mechanismopenlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); // some codeif (authorized_client()) { // do something} else { // unauthorized client! // log the attempt $access = date("Y/m/d H:i:s"); syslog(LOG_WARNING, "Unauthorized client: $access { $_SERVER['REMOTE_ADDR']} ({ $_SERVER['HTTP_USER_AGENT']} )"); } closelog(); ?>
注释
On Windows NT, the syslog service is emulated using the Event Log.
注意:
Use of
LOG_LOCAL0
throughLOG_LOCAL7
for thefacility
parameter of openlog() is not available in Windows.
参见
- openlog() - Open connection to system logger
- closelog() - 关闭系统日志链接
- syslog.filter INI setting (starting with PHP 7.3)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- checkdnsrr 给指定的主机(域名)或者IP地址做DNS通信检查(0)
- closelog 关闭系统日志链接(0)
- dns_check_record 别名 checkdnsrr()(0)
- dns_get_mx 别名 getmxrr()(0)
- dns_get_record 获取指定主机的DNS记录(0)
- fsockopen 打开一个网络连接或者一个Unix套接字连接(0)
- gethostbyaddr 获取指定的IP地址对应的主机名(0)
- gethostbyname 返回主机名对应的 IPv4地址。(0)
- gethostbynamel 获取互联网主机名对应的 IPv4 地址列表(0)
- gethostname 获取主机名(0)
- getmxrr 获取互联网主机名对应的 MX 记录(0)
- getprotobyname Get protocol number associated with protocol name(0)
- getprotobynumber Get protocol name associated with protocol number(0)
- getservbyname 获取互联网服务协议对应的端口(0)
- getservbyport Get Internet service which corresponds to port and protocol(0)
- header_register_callback 调用一个 header 函数(0)
- header_remove 删除之前设置的 HTTP 头(0)
- header 发送原生 HTTP 头(0)
- headers_list 返回已发送的 HTTP 响应头(或准备发送的)(0)
- headers_sent 检测 HTTP 头是否已经发送(0)
- http_response_code 获取/设置响应的 HTTP 状态码(0)
- inet_ntop Converts a packed internet address to a human readable representation(0)
- inet_pton Converts a human readable IP address to its packed in_addr representation(0)
- ip2long 将 IPV4 的字符串互联网协议转换成长整型数字(0)
- long2ip 将长整型转化为字符串形式带点的互联网标准格式地址(IPV4)(0)
- openlog Open connection to system logger(0)
- pfsockopen 打开一个持久的网络连接或者Unix套接字连接。(0)
- setcookie 发送 Cookie(0)
- setrawcookie 发送未经 URL 编码的 cookie(0)
- socket_get_status 别名 stream_get_meta_data()(0)
- socket_set_blocking 别名 stream_set_blocking()(0)
- socket_set_timeout 别名 stream_set_timeout()(0)
- syslog Generate a system log message(0)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)