[英]PHP Error log file format (php.ini error_log directive) on Windows
例如:
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
阿帕奇/ 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。
服务器:nginx 1.0.4
FastCGI + PHP 版本5.3.6
一切都按预期工作。
nginx phpinfo() 脚本 -> http://pastehtml.com/view/awvwvk9p9.html
还有更多的 ini 指令来控制 output 进入错误日志。 这些在PHP 手册页上进行了解释。
默认情况下,PHP 在不加载 ini 并且仅设置了error_log
并启用日志记录的情况下运行,它只执行 output 单行。 你也可以在你的系统上测试它,它很好地演示了命令行接口(CLI)“服务器应用程序编程接口(API)[SAPI]”:
php -n -d error_log=./error.log -d log_errors=1 -r 'error;'
使用此命令进行隔离运行并将其与您的 output 进行比较。 如果它也有两个行尾,那么这可能是您的 php 版本的错误。
如果 PHP 版本没有问题 [不是原始发布 (OP) 中的情况],那么在您的应用程序中,一些设置看起来会被更改。 您需要找出哪个设置。 可能您可以通过注册自己的错误处理程序然后转储 ini 设置来找到它。
最后但并非最不重要的一点是,如果这不是对行尾的误解(请参阅我的评论),那么人们可能还想查看名为error_prepend_string
和error_append_string
的有关错误显示的 ini 设置(但不是错误日志记录)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.