nginx / php-fpm错误日志logging

我试图找出PHP错误在我的设置中。 我正在运行nginx作为PHP-FPM的反向代理,但是我没有看到我的应用正在生成的各种E_NOTICEE_WARNING消息。 我知道他们正在发生的唯一原因是失败的响应和NewRelic捕捉堆栈跟踪。

这里是日志configuration:

nginx.conf

proxy_intercept_errors on; fastcgi_intercept_errors on; 

php.ini中

 error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = On error_log = syslog 

PHP-fpm.conf

 [global] error_log = /var/log/php-fpm/fpm-error.log [www] access.log = /var/log/php-fpm/access.log access.format = "%t \"%m %r%Q%q\" %s %{mili}dms %{kilo}Mkb %C%%" catch_workers_output = yes php_flag[display_errors] = on php_admin_flag[log_errors] = true 

rsyslog.conf

 :syslogtag, contains, "php" /var/log/php-fpm/error.log 

我configuration了PHP来login到系统日志,但FPM没有syslogfunction,所以它正在logging到一个文件。 我真的不在乎错误到底在哪里,只是它们到了某个地方。

任何线索我如何可以得到这个工作?

根据configuration文件,FPM确实支持向syslog发送错误。

 ; Error log file ; If it's set to "syslog", log is sent to syslogd instead of being written ; in a local file. ; Note: the default prefix is /var ; Default Value: log/php-fpm.log error_log = syslog ; syslog_facility is used to specify what type of program is logging the ; message. This lets syslogd specify that messages from different facilities ; will be handled differently. ; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) ; Default Value: daemon ;syslog.facility = daemon ; syslog_ident is prepended to every message. If you have multiple FPM ; instances running on the same server, you can change the default value ; which must suit common needs. ; Default Value: php-fpm ;syslog.ident = php-fpm ; Log level ; Possible Values: alert, error, warning, notice, debug ; Default Value: notice ;log_level = notice 

你确定你对rsyslog.conf的假设吗? 也就是说,你确定所有这样的系统日志消息都标有小写的“php”吗?

尝试将syslog.facility设置为local2(或local1或local7),并相应地replace您的rsyslog.confconfiguration行:

 local2.* /var/log/php-fpm/error.log