如何禁用.NET事件日志警告? [英] How To Disable .NET Event Log Warnings?

查看:340
本文介绍了如何禁用.NET事件日志警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我们的政策,我们不再允许写入事件日志,所以我删除了所有我的事件日志code从写入事件日志,它的工作原理,但我不断收到随机ASP.NET从4.0警告错误,即使我有code在我的Application_Error处理所有的错误。

任何方法来禁用事件记录完全,也许改变的web.config或IIS设置以禁用呢?

注意到它有很多的错误太..不只是我的HttpHandler

在事件日志记录的示例:


事件code:3005
事件消息:发生未处理的异常。
活动时间:2011/9/8上午10时26分04秒
事件时间(UTC):2011/9/8下午2时26分04秒
事件ID:6b56761296d24e1aa01038ce125be044
事件顺序:97
事件发生:1
事件详细信息code:0应用信息:
    应用领域:/ LM / W3SVC / 1 / ROOT / -2-129599642336131368
    信任级别:完整
    应用程序虚拟路径:/
    应用程序路径:
    机器名称:进程信息:
    进程ID:6396
    进程名:w3wp.exe
    帐户名:IIS APPPOOL \\ MyAppPool异常信息:
    异常类型:System.Exception的
    异常消息:堆栈跟踪


解决方案

ASP.NET的默认行为是编写的未处理的例外事件日志。从他们写入到事件日志以prevent它的方式是自己处理它们。您可以通过在Application_OnError处理您的Global.asax文件做到这一点。

您也可以向上冒泡到任何其他处理器调用Server.ClearError(),以prevent它。

Per our policy we are no longer allowed to write to event log, so I removed all my event log code from writing to the event log, which works, however I keep getting random ASP.NET 4.0 Warnings from the errors, even though I have code in my Application_Error to handle all errors.

Any way to disable event logging completely, maybe a web.config change or IIS setting to disable it?

Noticing it for a lot of errors too.. not just my HTTPHandler

Example of the EventLog record:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 9/8/2011 10:26:04 AM 
Event time (UTC): 9/8/2011 2:26:04 PM 
Event ID: 6b56761296d24e1aa01038ce125be044 
Event sequence: 97 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT/-2-129599642336131368 
    Trust level: Full 
    Application Virtual Path: /
    Application Path: 
    Machine name: 

Process information: 
    Process ID: 6396 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\MyAppPool

Exception information: 
    Exception type: System.Exception
    Exception message: STACKTRACE


解决方案

The default behavior of ASP.NET is to write unhandled exceptions to the event log. The way to prevent it from writing them to the event log is to handle them yourself. You can do this via your Global.asax file in the Application_OnError handler.

You can also call Server.ClearError() to prevent it from bubbling up to any other handlers.

这篇关于如何禁用.NET事件日志警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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