登录使用ELMAH事件日志错误 [英] Log errors in EventLog using ELMAH

查看:129
本文介绍了登录使用ELMAH事件日志错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ELMAH在我的asp.net MVC(C#)应用程序。记录错误

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

我能够在XML或数据库来记录错误。如何登录使用ELMAH错误事件日志?

I am able to log errors in xml or database. How to log errors to the eventlog using ELMAH?

推荐答案

ELMAH不包括一个事件日志选项。

ELMAH does not include an event log option.

ELMAH错误日志类不是只写;他们还读取日志数据,以便它可以在ELMAH网络界面被显示。此外,ELMAH记录的不仅仅是异常信息更多。它还记录服务器变量,形式收集和必要的信息以再现死亡的黄色屏幕。即使你记录所有这些信息到事件日志将难以阅读为纯文本,并且很难读回以这样的方式,该ELMAH web界面可以使用它。如果你不打算使用ELMAH Web界面那么显然这不是一个问题。

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.

如果您想记录基本的异常数据到事件日志中,您可以通过继承错误日志创建自己的错误日志。 ELMAH支持多种错误日志,所以你可以继续详细的数据记录到XML或数据库(以服务ELMAH Web界面),然后记录该数据的一个子集到事件日志。

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.

这篇关于登录使用ELMAH事件日志错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆