Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
启用PHP错误日志时,NGINX错误日志将被禁用_Php_Logging_Nginx - Fatal编程技术网

启用PHP错误日志时,NGINX错误日志将被禁用

启用PHP错误日志时,NGINX错误日志将被禁用,php,logging,nginx,Php,Logging,Nginx,我遇到了一种奇怪的行为。我正在用PHP-FPM运行NGINX 当我在PHP.ini中启用PHP错误日志时: error_log = /var/www/logs/php-scripts.error.log log_errors = on ; error_log = /var/www/logs/php-scripts.error.log <-- commented out log_errors = on 错误日志按预期写入: ... [15-Feb-2017 19:35:28 Etc/UT

我遇到了一种奇怪的行为。我正在用PHP-FPM运行NGINX

当我在
PHP.ini
中启用PHP错误日志时:

error_log = /var/www/logs/php-scripts.error.log
log_errors = on
; error_log = /var/www/logs/php-scripts.error.log <-- commented out
log_errors = on
错误日志按预期写入:

...
[15-Feb-2017 19:35:28 Etc/UTC] PHP Parse error:  syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7
但是,与此同时,在my NGINX vhost中配置的错误日志根本不会写入(这是NGINX配置片段):

NGINX错误日志被写入

...
2017/02/16 12:01:44 [error] 13#13: *27 FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7" while reading response header from upstream, client: 172.19.0.2, server: domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "domain.com:8080"

我完全不理解这种行为。两个测井系统之间的干扰源是什么?为什么我不能在
php.ini
中启用错误日志,同时写入NGINX的错误日志?现在不是一个就是另一个。有可能克服这个问题吗?

PHP会将错误报告到日志文件、syslog(3)或stderr中,具体取决于是否以及如何设置
错误日志。有关详细信息,请参阅

nginx
将记录它通过FastCGI stderr流接收到的消息


因此,这并不是很奇怪的行为。

如果我理解正确,关键是如果我将PHP错误重定向到一个文件,错误不会发送到stderr,因此,nginx将没有任何流可读取,其错误日志将为空。。
...
2017/02/16 12:01:44 [error] 13#13: *27 FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7" while reading response header from upstream, client: 172.19.0.2, server: domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "domain.com:8080"