异常、Global.asax 和事件日志
我想将未处理的异常从 global.asax 记录到应用程序事件日志中。 但是,我注意到 IIS 已经将这些未处理的异常记录为警告。 有没有办法抑制这些消息,因为我打算自己记录它们,或者您认为在其中同时包含这两个条目(IIS 记录的事件日志条目和我的事件日志条目)是否合理?
更新:
谢谢约翰·桑德斯为我指明了正确的方向。 事实上,健康监控正在根据默认配置进行日志记录 在根 web.config 中。
I would like to log unhandled exceptions from the global.asax to the Application eventlog. However, I've noticed that IIS is already logging these unhandled exceptions as warnings. Is there a way to suppress these messages since I'm planning on logging them myself or do you think it’s reasonable to have both entries there (the event log entry logged by IIS and my event log entry)?
UPDATE:
Thank you John Saunders for pointing me in the right direction. It was in fact health montioring that was doing the logging based on the default configuration in the root web.config.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您最好找出这些条目是什么。 它们不是来自 IIS,而是来自 ASP.NET 运行状况监控。
这是一个可扩展的机制,您可能想要扩展它而不是自己推出。 例如,将其配置为记录应用程序的启动和结束,以便跟踪 AppDomain 的重新启动是很简单的。 您还可以将数据添加到它记录的“网络事件”中,并配置日志信息的发送位置。
请参阅 ASP.NET 运行状况监控概述。
You would do better to find out what those entries are. They're not from IIS, they're from ASP.NET Health Monitoring.
That's an extensible mechanism, and you may want to extend it instead of rolling your own. For instance, it's trivial to conifgure it to also log application start and end, in order to keep track of AppDomain restarts. You can also add data tot he "web events" that it logs, and configure where the log information will be sent.
See ASP.NET Health Monitoring Overview.
这是我几个月前写的一篇关于通过 ASP.NET MVC3 使用 ASP.NET 运行状况监控的博客文章。
http://mattfrear.com/2011/01/28/mvc3-logging-例外/
-马特
Here's a blog post I wrote a few months ago on using ASP.NET Health monitoring with ASP.NET MVC3.
http://mattfrear.com/2011/01/28/mvc3-logging-exceptions/
-Matt