elmah customized provider and exposed event

天涯浪子 提交于 2019-12-05 14:50:19
PHeiberg

About creating an Elmah Event Log provider it's probably not a good idea if you intend to store the error information in the event log and also use the ELMAH UI. A related question has an excellent answer from Matthew Daugherty on this topic:

ELMAH error log classes are not write-only; they also read the log data so that it can be displayed in the ELMAH web interface. Additionally, ELMAH logs more than just exception information. It also logs server variables, the form collection, and the information necessary to reproduce the yellow screen of death. Even if you were to log all of this information to the event log it would be difficult to read as plain text, and very difficult to read back in such a way that the ELMAH web interface could use it. If you are not going to use the ELMAH web interface then clearly that is not an issue.

In order to create a custom logging provider you can subclass ErrorLog and override the GetError (gets a single error by id; used by the Elmah UI), GetErrors (lists all errors on a page; used by the Elmah UI) and Log (logs a new error) methods to provide your own storage mechanism. See this article for an examle on how to implement a custom ErrorLog.

You then register your new ErrorLog provider in the config:

<elmah> 
  <errorLog type="MyNamespace.MyErrorLog, MyAssemblyName"/> 
</elmah> 

Regarding the events, they are emitted by the Elmah modules. In the ErrorLogModule there are two events - Logged and Filtering. In the ErrorMailModule there are four events - Filtering, Mailing, Mailed and DisposingMail.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!