ELMAH 设置 - 错误未被捕获
我已经按照示例应用程序完全设置了 ELMAH。我尝试使用以下方法抛出错误来测试 ELMAH:
throw new InvalidOperationException();
不幸的是,我的应用程序直接出现错误,而 ELMAH 没有捕获/记录错误。我正在使用 ASP.NET 3.5。我不确定我做错了什么,因为 Web.Config 与示例完全相同
I've setup ELMAH exactly as with the sample app. I attempt to throw an error to test ELMAH by using:
throw new InvalidOperationException();
Unfortunately however my app is going straight to the error and ELMAH is not catching/logging the error. I am using ASP.NET 3.5. I am not sure what I am doing wrong as the Web.Config is exactly the same as the sample
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仔细检查您的 Web.config。我遇到了同样的问题,直到我意识到我忘记注册模块。
我发现 dotnetslackers 上的这篇文章很有帮助。
Double check your Web.config. I had the same problem until I realized I forgot to register the module.
I found this article over on dotnetslackers helpful.
由于 Elmah 是开源的,因此您应该将代码作为项目添加到解决方案中,并确保 Visual Studio 能够中断所有异常。 Elmah 抛出一个会被吞掉的异常听起来是可行的。这正是发生在我身上的事情,这是插入错误的存储过程的权限。
原创
您的测试是否在 try/catch 块内?如果是这样,您必须显式强制进行日志记录。
我的WEB.CONFIG设置
Since Elmah is open source, you should add the code as a project in your solution and make sure that you have visual studio break on all exceptions. It sounds feasible that Elmah is throwing an Exception which would be swallowed. This exact thing was happening with me and it was a permission on the stored procedure that inserts the error.
ORIGINAL
Is your test within a try/catch block? If so, you'll have to explicitly force the logging to occur.
MY WEB.CONFIG SETUP