【问题标题】:Error signalling in ELMAH not working with ASP.NET MVCELMAH 中的错误信号不适用于 ASP.NET MVC
【发布时间】: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


    【解决方案1】:

    我将 Elmah 与 .NET MVC 一起使用,并以编程方式引发 Elmah 异常对我有用。我可能在这里抓住了一根稻草,但是从 Elmah 网站上 this page 的第四条评论来看,Web.config 中包含几行不在上面的示例中。

    可能是你没有在你的 sn-p 中包含这些行,但我想我还是把它扔在那里

    【讨论】:

    • 谢谢菲尔...解决了这个问题。在部署到我正在使用的 IIS7 时,我们似乎需要这些标签。 ELMAH 的信号无声无息地失效,这让问题变得更加神秘。在这里找到了更详细的解释stackoverflow.com/questions/933554/…
    猜你喜欢
    • 2011-01-08
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-20
    • 1970-01-01
    • 2014-05-10
    相关资源
    最近更新 更多