加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows上的PHP错误日志文件格式(php.ini error_log指令)

发布时间:2020-12-13 20:34:11 所属栏目: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:wwwphpinfo.php on line 2 rrn [
举个例子:
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:wwwphpinfo.php on line 2rrn
[12-Jun-2011 12:59:01] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rrn
[12-Jun-2011 13:01:12] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rrn
[12-Jun-2011 13:02:11] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rrn
[12-Jun-2011 13:11:23] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rrn
[12-Jun-2011 13:12:10] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rrn

每个错误行有两个回车字符和一个新行.

为什么会这样?
如何将错误日志文件更改为默认格式:

[12-Jun-2011 12:58:55] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn
[12-Jun-2011 12:59:01] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn
[12-Jun-2011 13:01:12] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn
[12-Jun-2011 13:02:11] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn
[12-Jun-2011 13:11:23] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn
[12-Jun-2011 13:12:10] PHP Notice:  Undefined variable: test in C:wwwphpinfo.php on line 2rn

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设置来找到它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读