如何让ELMAH使用ASP.NET MVC [HandleError]属性?

允我心安 提交于 2020-08-16 09:20:57

问题:

I am trying to use ELMAH to log errors in my ASP.NET MVC application, however when I use the [HandleError] attribute on my controllers ELMAH doesn't log any errors when they occur. 我正在尝试使用ELMAH来记录我的ASP.NET MVC应用程序中的错误,但是当我在控制器上使用[HandleError]属性时,ELMAH在发生错误时不会记录任何错误。

As I am guessing its because ELMAH only logs unhandled errors and the [HandleError] attribute is handling the error so thus no need to log it. 正如我猜测它,因为ELMAH只记录未处理的错误,[HandleError]属性正在处理错误,因此无需记录它。

How do I modify or how would I go about modifying the attribute so ELMAH can know that there was an error and log it.. 我如何修改或如何修改属性,以便ELMAH可以知道有错误并记录它..

Edit: Let me make sure everyone understands, I know I can modify the attribute thats not the question I'm asking... ELMAH gets bypassed when using the handleerror attribute meaning it won't see that there was an error because it was handled already by the attribute... What I am asking is there a way to make ELMAH see the error and log it even though the attribute handled it...I searched around and don't see any methods to call to force it to log the error.... 编辑:让我确保每个人都理解,我知道我可以修改那个不是我问的问题的属性... ELMAH在使用handleerror属性时会被绕过,这意味着它不会看到有错误因为它被处理了已经由属性...我要问的是有一种方法让ELMAH看到错误并记录它即使属性处理它...我搜索周围,没有看到任何方法调用强制它来记录错误....


解决方案:

参考一: https://stackoom.com/question/3DQg/如何让ELMAH使用ASP-NET-MVC-HandleError-属性
参考二: https://oldbug.net/q/3DQg/How-to-get-ELMAH-to-work-with-ASP-NET-MVC-HandleError-attribute
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!