【发布时间】:2011-04-18 03:41:30
【问题描述】:
我的理解是,引发错误信号应该记录我的错误或点击自定义 HandleErrorWithELMAHAttribute 类(取自此example),但两者都没有。
我正在为有问题的控制器使用 HandleErrorWithElmah 装饰器。当涉及到控制器中未处理的异常时,错误日志记录有效(我明确调用 Logexception 并且没有使用example 第二个代码块中提到的条件)。但是用于处理错误的错误信号功能让我感到困惑。错误信号是如何工作的...它是否应该做除 Logging 之外的其他事情...如果是这样,我如何使用它记录我处理的异常?
这是我用来表示处理错误的代码
ErrorSignal.FromCurrentContext().Raise(new Exception("Some Handled Error"));
下面是我在 web config 中设置的 sn-ps
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Log" />
</elmah>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
【问题讨论】:
标签: c# model-view-controller error-handling elmah