Elmah 总是记录两个相同的异常:知道为什么吗?
我在许多项目中使用了 Elmah,每个项目都会为每个异常生成两个相同的日志记录。除了混乱和浪费空间之外,它的工作正常。
有人以前见过这种行为或者知道从哪里开始寻找吗?
编辑:{from global.asax.cs}
protected void Application_Error() {
// Use ELMAH to log the exception
var exception = Server.GetLastError();
var context = HttpContext.Current;
var signal = ErrorSignal.FromContext(context);
if (signal != null) {
signal.Raise(exception, context);
}
// Show custom error page if necessary
if (!_showCustomErrorPages) return;
if (exception is HttpRequestValidationException) {
DisplayErrorPage("InvalidInput");
return;
}
DisplayErrorPage("Error");
}
这是我在“whocanhelpme”项目中使用的示例代码。
I've used Elmah in a number of projects and in each of them two identical log records are generated for each and every exception. Besides the clutter and waste of space its working fine otherwise.
Has anyone seen this behavior before or have a clue where to start looking?
EDIT: {from global.asax.cs}
protected void Application_Error() {
// Use ELMAH to log the exception
var exception = Server.GetLastError();
var context = HttpContext.Current;
var signal = ErrorSignal.FromContext(context);
if (signal != null) {
signal.Raise(exception, context);
}
// Show custom error page if necessary
if (!_showCustomErrorPages) return;
if (exception is HttpRequestValidationException) {
DisplayErrorPage("InvalidInput");
return;
}
DisplayErrorPage("Error");
}
this is example code I was using from the "whocanhelpme" project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在
Web.config
中注册了两次 ELMAH 错误日志记录模块?可以在
system.web\httpModules
中拥有一次,在system.webServer\modules
中拥有一次,但我最初的想法是,也许您已将其注册两次 在这些部分的一个(或多个)中。也许您可以编辑您的问题以包含Web.config
文件的内容(当然,删除任何敏感信息,例如电子邮件设置或连接字符串)?另一个想法 - 你在 Global.asax 中有一个
Application_OnError
事件处理程序吗?如果是这样,您是否在其中执行了任何可能导致 ELMAH 再次记录错误的操作?Do you have the ELMAH error logging module registered twice in
Web.config
, perhaps?It's ok to have it once in
system.web\httpModules
and once insystem.webServer\modules
, but my initial thought was that maybe you have it registered twice in one (or more) of these sections. Perhaps you could edit your question to include the contents of yourWeb.config
file (of course, removing any sensitive information like email settings or connection strings)?Another thought - do you have an
Application_OnError
event handler inGlobal.asax
, per chance? If so, are you doing anything in there that might cause ELMAH to log the error a second time?