我在许多项目中使用了Elmah,并且在每个项目中都为每个例外生成了两个相同的日志记录。除了空间的混乱和浪费,否则其工作正常。
之前有没有人见过这种行为或者有线索从哪里开始看?
编辑:{来自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”项目中使用的示例代码。
答案 0 :(得分:2)
您是否在Web.config
中注册了两次ELMAH错误记录模块?
可以在system.web\httpModules
中使用一次,在system.webServer\modules
中使用一次,但我最初的想法是,您可能在一个(或多个)中注册了两次这些部分。也许您可以编辑您的问题以包含Web.config
文件的内容(当然,删除任何敏感信息,如电子邮件设置或连接字符串)?
另一个想法 - 你有机会在Application_OnError
中有一个Global.asax
事件处理程序吗?如果是这样,你在那里做任何可能导致ELMAH再次记录错误的事情吗?