举个例子:
php.ini文件
php.ini文件
... ; Log errors to specified file. error_log = c:/php/php.log ...
错误日志文件(c:/php/php.log)包含此格式的每个条目:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n [12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n [12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n [12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n [12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n [12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
每个错误行有两个回车字符和一个新行.
为什么会这样?
如何将错误日志文件更改为默认格式:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n [12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n [12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n [12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n [12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n [12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
PHP版本5.3.6
Apache / 2.2.15(Win32)
在Windows 7 Home Basic和Windows XP SP3上测试,结果相同.
php.ini文件只包含两个字符串
log_errors = On error_log = c:/server/php.log
apache phpinfo()脚本 – > http://pastehtml.com/view/awvx1vgpp.html
PS.
sever:nginx 1.0.4
FastCGI PHP版本5.3.6
一切都按预期工作.
nginx phpinfo()脚本 – > http://pastehtml.com/view/awvwvk9p9.html
有更多的ini指令来控制输出到错误日志中.如果它不是对行结尾的误解(请参阅我的注释),那么您可能希望查看error_prepend_string和error_append_string的ini设置.这些两个和更多相关的设置在
this PHP manual page上解释.
默认情况下,PHP运行时没有加载ini并且只启用了error_log并启用了日志记录,它只输出一行.您也可以在系统上测试它:
php -n -d error_log=./error.log -d log_errors=1 -r 'error;'
使用此命令进行隔离运行并将其与输出进行比较.如果它有两个行结尾,那么这可能是你的php版本的错误.
如果没有,则在您的应用程序中,某些设置看起来会被更改你需要找出哪个设置.也许您可以通过注册own error handler然后使用ini设置来找到它.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。