开发者

Log errors in EventLog using ELMAH

I am using ELMAH to log errors in my asp.net MVC(C#) application.

I am able to log errors in xml or database. How to 开发者_JAVA百科log errors to the eventlog using ELMAH?


ELMAH does not include an event log option.

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.

If you want to log basic exception data to the event log you can create your own error log by subclassing ErrorLog. ELMAH supports multiple error logs, so you could continue to log detailed data to XML or a database (to service the ELMAH web interface) and then log a subset of that data to the event log.


Out of the box, you can't. You'd have to write a custom handler.


You can do something like this.

Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("My Exception");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜