带有 customErrors 的 elmah 不会发送电子邮件,除非是 404
我正在尝试 Elmah,看看我是否想使用它作为我的错误处理解决方案。我安装了它,将异常硬编码到我的页面中,点击页面 wholla!收到我的电子邮件,一切都很高兴。但是,当我将 customError 节点添加到 web.config 以重定向到友好错误页面时,电子邮件未发送,但我被重定向到我的友好错误页面。
奇怪的是,当我浏览到我的网站上不存在的页面时,我被重定向到主页(正如我在自定义错误中设置的那样),但我确实收到了电子邮件......这可能会出现问题,因为我不想当人们访问我的网站并在网址末尾添加“whatever.php”时,我会收到十亿封电子邮件。
所以我有两个问题:1)为什么抛出的异常不会向我发送电子邮件,2)我如何告诉 Elmah 不要向我发送 404 电子邮件?
I am playing around with Elmah to see if I want to use that as my error handling solution. I installed it, hard coded an exception into my page, hit the page wholla! Got my email, everything is happy. However, when I added the customError node to my web.config to redirect to a friendly error page, the email was not sent but I was redirected to my friendly error page.
Strangely, when I browsed to a page that doesn't exist on my site, I was redirected to home (as I set in my customErrors) but I DID receive the email...that could be problematic as I don't want to get a billion emails when people hit my site and add "whatever.php" to the end of the url.
So I have two questions: 1) why would the exception that is being thrown NOT send me an email and 2) how can I tell Elmah NOT to send me emails for 404s?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Global.asax.cs 中使用 elmah 过滤内容:
因此将对 FilterError404 的调用添加到过滤的任何部分。上面的示例将为 ErrorLog 和 Email 过滤 404。另请查看:
http://code.google.com/p/elmah/wiki/ErrorFiltering
您还可以按源进行过滤,如链接中所述:
检查 web.config:
仅供参考:NuGET 包也可用,如 Scott Hanselman 所解释的:
http://www.hanselman.com/blog/NuGetPackageOfTheWeek7ELMAHErrorLoggingModulesAndHandlersWithSQLServerCompact.aspx
You can filter things with elmah like such in your Global.asax.cs:
So add the call to FilterError404 to any part of the filtering. The above example will have it filter 404 for both ErrorLog and Email. Also check out:
http://code.google.com/p/elmah/wiki/ErrorFiltering
You can also do Filtering By Source as described in the link:
Check web.config:
FYI: NuGET Package also available as explained by Scott Hanselman:
http://www.hanselman.com/blog/NuGetPackageOfTheWeek7ELMAHErrorLoggingModulesAndHandlersWithSQLServerCompact.aspx