在 PHP 中使用 WAMP 服务器记录错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9230984/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:24:01  来源:igfitidea点击:

Error logging with WAMP server in PHP

phpwampwampservererror-logging

提问by Yarin

I have a WAMP 2.2 server running on a Windows 7 box and cannot get PHP error logging working at all.

我有一个 WAMP 2.2 服务器在 Windows 7 机器上运行,根本无法让 PHP 错误日志记录工作。

The file is always blank even after I explicitly trigger USER_ERROR errors, or cause normal ERROR errors.

即使在我明确触发 USER_ERROR 错误或导致正常的 ERROR 错误之后,该文件也始终为空白。

I'm including the error relevant sections of the php.inifile - hopefully you can find something:

我包括了php.ini文件的错误相关部分- 希望你能找到一些东西:

error_reporting = E_ALL

error_log = "c:/wamp32/logs/php_error.log" ;(UNCOMMENTED BY ME)

log_errors = On
display_errors = On

采纳答案by JYelton

The line ; log_errorsis just a comment for the following block, for the purpose of showing you what the settings are in dev vs production. You uncommented four lines which aren't meant to control anything, and I'm surprised your Apache service doesn't have problems starting up because of it.

该行; log_errors只是对以下块的注释,目的是向您展示开发与生产中的设置。您取消了四行的注释,这些行并不意味着控制任何东西,我很惊讶您的 Apache 服务没有因此启动问题。

What you need to do is look for the line:

您需要做的是查找该行:

log_errors = Off

And change the value to On

并将值更改为 On

That said, once you restart the Apache service, the settings should take effect. However, I was unable to get WampServer to properly log php errors despite these settings. Apache will not start up when I specify the error_logparameter.

也就是说,一旦您重新启动 Apache 服务,设置就会生效。但是,尽管有这些设置,我还是无法让 WampServer 正确记录 php 错误。当我指定error_log参数时,Apache 不会启动。

回答by eklingen

For me it turned out to be a permissions error. I ended up giving EVERYONE full control of the error log file and it seemed to fix my issue. Best of luck.

对我来说,结果证明是权限错误。我最终让每个人都完全控制了错误日志文件,它似乎解决了我的问题。祝你好运。