每次Elmah记录一个错误,错误记录两次。与完全相同的时间戳100%相同。 我在web.config中没有特别的配置。 我已经创建了一个ElmahHandleErrorAttribute添加的两个过滤器:elmah与mvc记录两次
filters.Add(new ElmahHandleErrorAttribute {
ExceptionType = typeof(System.Data.Common.DbException),
// DbError.cshtml is a view in the Shared folder.
View = "DbError",
Order = 2
});
filters.Add(new ElmahHandleErrorAttribute {
ExceptionType = typeof(Exception),
// DbError.cshtml is a view in the Shared folder.
View = "Error",
Order = 3
});
从web.config中的一些片段:
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
和
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
在ElmaHandleErrorAttribute此代码:
public override void OnException(ExceptionContext context) {
base.OnException(context);
if (!context.ExceptionHandled
|| TryRaiseErrorSignal(context)
|| IsFiltered(context))
return;
LogException(context);
}
我搜索了很多,但没有解决方案适合我的问题。在web.config中没有双重条目或类似的东西。
这不是什么大问题,但是很烦人。
THX提前
©A-X-我
你是不是在您的自定义ElmaHandleErrorAttribute检查ExceptionType。所以它会被称为2次。因为DbException是从Exception中继承的。 – VahidN
请参阅我对这个类似的问题的建议的答案http://stackoverflow.com/a/16794746/589827 – DGreen