启用自定义错误时,Elmah 不会触发
当我禁用自定义错误时,Elmah 会记录发生的所有异常并将它们记录到我的数据库中并通过电子邮件发送给我。
然而,当我将 web.config 更改为:
<customErrors mode="RemoteOnly" defaultRedirect="~/Home/Error">
</customErrors>
Elmah 停止运行时。它不再将异常记录到数据库或任何其他内容,我所看到的只是正在执行的自定义错误操作。
如何在拥有自定义错误消息的同时仍然存在 elmah 日志异常?除了 Elmah 之外,我目前没有进行任何其他异常拦截。
When I have my custom errors disabled, Elmah is taking all exceptions that occur and logging them into my database and emailing me.
However, the second I change my web.config to:
<customErrors mode="RemoteOnly" defaultRedirect="~/Home/Error">
</customErrors>
Elmah stops functioning. It no longer logs exceptions to the database or anything, all I see is my custom error action being executed.
How can I have custom error messages and still have elmah log exceptions? I am currently not doing any other exception intercepting besides Elmah.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了!
发生这种情况的原因是因为我在
Global.asax
中有filters.Add(new HandleErrorAttribute());
。我不知道为什么会出现这种情况,但这就是启用自定义错误时导致失败的原因。删除这一行会导致 Elmah 正常工作并出现自定义错误。此外,告诉 elmah 记录“已处理”错误也有效,如 这个答案。
不过,我并不真正了解这两种选择的全部后果。
Figured it out!
The reason this was occurring was because I had
filters.Add(new HandleErrorAttribute());
inGlobal.asax
. I don't know why this is there, but that was what was causing this to fail when custom errors was enabled. Removing this line caused Elmah to work properly with custom errors.Also, telling elmah to log "handled" errors also works, as described by this answer.
I don't truely know the full ramifications of either option though.