Ser*_*y L 6 php windows newline error-log
例如:
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 Version 5.3.6
一切都按预期工作.
nginx phpinfo()脚本 - > http://pastehtml.com/view/awvwvk9p9.html
还有更多 ini 指令来控制错误日志的输出。此 PHP 手册页对此进行了解释。
默认情况下,PHP 在不加载 ini 且仅启用error_log设置和日志记录的情况下运行,它只输出一行。您也可以在您的系统上进行测试,它很好地演示了命令行界面 (CLI)“服务器应用程序编程接口 (API) [SAPI]”:
php -n -d error_log=./error.log -d log_errors=1 -r 'error;'
Run Code Online (Sandbox Code Playgroud)
使用此命令进行独立运行并将其与输出进行比较。如果它也有两个行结尾,那么这可能是你的 php 版本的错误。
如果 PHP 版本没有问题 [原始帖子 (OP) 中的情况并非如此],那么在您的应用程序中,某些设置看起来会被更改。您需要找出哪个设置。也许您可以通过注册自己的错误处理程序然后转储 ini 设置来找到它。
最后但并非最不重要的一点是,如果不是对行结尾的误解(请参阅我的评论),那么人们可能还想查看命名的 ini 设置error_prepend_string和error_append_string有关错误显示的内容(但不是错误日志记录)。