windows IIS PHP 不会将错误记录到日志文件中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6661688/
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-09-15 17:23:53  来源:igfitidea点击:

IIS PHP doesn't log errors to log file

phpwindowsiiserror-log

提问by Tural Ali

My local windows webserver (IIS) doesn't log php errors to log file.The php53_errors.log file is always empty. http://prntscr.com/2aelsHow to fix it? I think something goes wrong with permission settings. But it shows errors on browser window. And, one more question:Notices like "Undefined index".. Are they really important?

我的本地 Windows 网络服务器 (IIS) 不会将 php 错误记录到日志文件中。php53_errors.log 文件始终为空。http://prntscr.com/2aels如何解决?我认为权限设置有问题。但它在浏览器窗口上显示错误。还有一个问题:像“未定义索引”这样的通知......它们真的很重要吗?

采纳答案by Spudley

Read the last part of your question:

阅读问题的最后一部分:

Notices like "Undefined index".. Are they really important?

诸如“未定义索引”之类的通知......它们真的很重要吗?

It depends on your definition of 'important'.

这取决于您对“重要”的定义。

The easy answer is no, they're not important. That's the reason they're classified as notices rather than warnings. It's okay to ignore them.

简单的答案是否定的,它们并不重要。这就是它们被归类为通知而不是警告的原因。可以忽略它们。

However you should still pay attention to them, and try to fix them where possible.

但是,您仍然应该注意它们,并在可能的情况下尝试修复它们。

For example, the notice you quoted "Undefined index". This is caused (as I'm sure you're aware) by referencing an array element that hasn't yet been defined.

例如,您引用了“未定义索引”的通知。这是通过引用尚未定义的数组元素引起的(我相信您知道)。

It is best practice to prevent this notice from being raised by using isset(), because if you do that, then when you do still get the notice, you'll know it is important - maybe you made a typo in your variable name or array index? The code will still run, but it won't work properly, and getting the notice might be the first clue you have of that. If that notice is suppressed or drowned out by legitimate ones, you'll never spot it.

最好的做法是使用 防止出现此通知isset(),因为如果您这样做了,那么当您仍然收到通知时,您就会知道这很重要 - 也许您在变量名或数组索引中打错了字?代码仍会运行,但无法正常运行,收到通知可能是您获得的第一个线索。如果该通知被合法通知压制或淹没,您将永远不会发现它。

Most 'notices' raised by PHP are on a similar level to that -- they indicate that something might be wrong, but PHP doesn't know for sure. If you write your code defensively to prevent notices from being raised when you're happy with the code, then you can afford to pay more attention to the ones that do still crop up.

PHP 提出的大多数“通知”都与此类似——它们表明可能有问题,但 PHP 并不确定。如果您防御性地编写代码以防止在您对代码感到满意时发出通知,那么您可以更多地关注仍然出现的那些。

Hope that helps.

希望有帮助。

回答by yanyanqq

In the IIS server manager tool, there is option call error page. Please disable to use the IE error page to show you the error.

在 IIS 服务器管理器工具中,有选项调用错误页面。请禁用以使用 IE 错误页面向您显示错误。

Besides please go to the C:\inetpub\wwwroot\web.configthis file controls how to display and log the error as well. It should have one line like this. <httpErrors errorMode="Detailed" />

此外,请转到C:\inetpub\wwwroot\web.config此文件控制如何显示和记录错误。它应该有这样的一行。 <httpErrors errorMode="Detailed" />

回答by Marek Sebera

Do you have php.ini in right setup according to this?

根据这个,你有正确设置的 php.ini 吗?

http://php.net/manual/en/install.windows.manual.php

http://php.net/manual/en/install.windows.manual.php

specially keys log_errorsand error_log

特别是钥匙log_errorserror_log