带有专用错误日志文件的 PHP-FPM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14344316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:06:11  来源:igfitidea点击:

PHP-FPM with dedicated error log file

loggingphp

提问by Dan

I've set up an Apache2/PHP-FPM site and would like PHP-FPM's errors to be logged to its own error log file. However, with the current configuration, the errors are being logged to /var/log/php5-fpm.log in the following format:

我已经建立了一个 Apache2/PHP-FPM 站点,并希望将 PHP-FPM 的错误记录到它自己的错误日志文件中。但是,使用当前配置,错误以以下格式记录到 /var/log/php5-fpm.log 中:

WARNING: [pool www] child 22926 said into stderr: "NOTICE: PHP message: PHP Parse error:  syntax error, unexpected 'if' (T_IF) in /var/www/site.com/error.php on line 1"

In my /etc/php5/fpm/pool.d/www.conf I have the following options:

在我的 /etc/php5/fpm/pool.d/www.conf 我有以下选项:

php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
catch_workers_output = yes

When I disable catch_workers_output, the error logging ceases completely. However, in phpinfo() output, it is showing the logfile I specify in the configuration.

当我 disable 时catch_workers_output,错误日志记录完全停止。但是,在 phpinfo() 输出中,它显示了我在配置中指定的日志文件。

Why is PHP5-FPM not respecting this logfile. Is there any way to have errors for the fpm pool logged in a separate file?

为什么 PHP5-FPM 不尊重这个日志文件。有没有办法将 fpm 池的错误记录在单独的文件中?

My php version:

我的 php 版本:

# php5-fpm  -v
PHP 5.4.9-4~precise+1 (fpm-fcgi) (built: Nov 30 2012 10:48:01)

Thank you for any information!

感谢您提供任何信息!

采纳答案by Diemuzi

You'll find the error_log = /var/log/php-fpm.log in your main FPM Configuration. Based on your example you are setting this in a Pool configuration, which will only work for that specific pool/domain.

您将在主 FPM 配置中找到 error_log = /var/log/php-fpm.log。根据您的示例,您将在池配置中进行设置,该配置仅适用于该特定池/域。