从Apache(mpm prefork)转换到php5-fpm的Nginx,我发现错误日志不愉快的parsing。
例如Nginx会产生这样的东西(具体的编辑):
2012/03/12 09:56:59 [error] 22075#0: *432 FastCGI sent in stderr: "PHP Warning: require_once([somefile]): failed to open stream: No such file or directory in [sourcefile] on line 6 PHP Fatal error: require_once(): Failed opening required '[somefile]' (include_path='.:/usr/share/php:/usr/share/pear') in [sourcefile] on line 6" while reading response header from upstream, client: [ip], server: [host].*, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "[host]"
其中包含了大量的信息,我没有真正感兴趣的99%的时间,而开发/debugging。
Apache用来输出更可读的东西,比如:
[date] [error] [client] PHP Warning: require_once([somefile]): failed to open stream: No such file or directory in [sourcefile] on line 6 [date] [error] [client] PHP Fatal error: require_once(): Failed opening required '[somefile]' (include_path='.:/usr/share/php:/usr/share/pear') in [sourcefile] on line 6"
由于实际的错误首先出现(与FPM细节相对)并且在terminal中列alignment,因此大多更容易扫描。
有什么办法可以让Nginx的行为更像Apache的错误日志?