【问题标题】:PHP-FPM how do I suppress notice log level and still capture warning log /etc/php-fpm.confPHP-FPM如何抑制通知日志级别并仍然捕获警告日志/etc/php-fpm.conf
【发布时间】:2015-02-07 17:01:41
【问题描述】:

我无法弄清楚如何在 php-fpm 中抑制通知级别的日志事件,例如:

[07-Feb-2015 10:06:48] NOTICE: [pool www] child 19591 exited with code 0 after 52040.698062 seconds from start
[07-Feb-2015 10:06:49] NOTICE: [pool www] child 17234 started
[07-Feb-2015 10:06:50] NOTICE: [pool www] child 19822 exited with code 0 after 52014.845635 seconds from start
[07-Feb-2015 10:06:50] NOTICE: [pool www] child 17261 started
[07-Feb-2015 10:07:33] NOTICE: [pool www] child 17784 exited with code 0 after 52246.014015 seconds from start

同时仍然捕获类型为警告的日志事件,例如由 php 中的 error_log() 函数创建的。记录如下事件:

 [07-Feb-2015 11:46:44] WARNING: [pool www] child 32465 said into stderr: "NOTICE: PHP message: Array"
 [07-Feb-2015 11:46:44] WARNING: [pool www] child 32465 said into stderr: "("
 [07-Feb-2015 11:46:44] WARNING: [pool www] child 32465 said into stderr: "     [6] => 363"
 [07-Feb-2015 11:46:44] WARNING: [pool www] child 32465 said into stderr: ")"
 [07-Feb-2015 11:46:44] WARNING: [pool www] child 32465 said into stderr: ""

来自 php.net,它声明变量 log_level 接受以下字符串类型以调整捕获的日志记录级别:

错误日志级别。可能的值:警报、错误、警告、通知、调试。默认值:通知。

http://php.net/manual/en/install.fpm.configuration.php

所以,很自然地,在我的 /etc/php-fpm.conf 文件中,我将配置值设置为: log_level:警告和服务重启。然后我没有得到上述日志事件。

我找不到任何地方的文档表明每个 log_level 选项的作用,而且似乎除了通知之外的任何东西都会抑制一切。

这是在 centOS 机器上使用 php-fpm 5.4 或 5.5。

【问题讨论】:

  • 我和我的团队在 PHP 7.0 上遇到了同样的问题,部署在基于 Ubuntu 的 Docker 映像中。

标签: configuration php


【解决方案1】:

我遇到了同样的问题。我通过更改相应 php.ini 中的 error_reporting 来消除通知。

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE

这意味着:报告所有错误,但 deprecation、strict 和 notice 类型除外。

日志级别似乎是错误的调整位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-12
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多