如何禁用.NET事件日志警告?

编程入门 行业动态 更新时间:2024-10-08 10:54:46
本文介绍了如何禁用.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事件日志警告?

本文发布于:2023-11-25 21:28:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631415.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   日志   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!