Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Disable .NET Event Log Warnings?

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


like image 248
jaekie Avatar asked Jan 11 '12 18:01

jaekie


People also ask

Can I disable event log?

Disable individual logs Open the Windows Event Viewer: press Windows R , type eventvwr. msc and press Enter . Scroll down to Application and Service Logs , Microsoft , Windows , WFP . Right-click on a log process and select Disable Log .

How do I stop Event Log service?

To disable Windows Event Log service, open the Services window, find the Windows Event Log service, and set it to Disabled. Log Service is a Windows service that manages the event logs on a computer.

What happens if I disable Windows event log?

Disabling logging to the Windows Application log enables you to limit the amount of data that is stored. If you are using System Center Operations Manager to monitor Business Central Server do not disable logging to the Windows Application log.


2 Answers

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.

like image 90
Steven Avatar answered Sep 18 '22 08:09

Steven


It's true that the default behavior is to log all unhandled exceptions to Application event log as explained in this answer. This behavior is controlled by <system.web><healthMonitoring> element in web.config and default settings are shown here. The idea is that for every unhandled exception an instance of System.Web.Management.WebBaseErrorEvent is raised and then ASP.NET default settings cause it to be logged into Application event log.

You could handle all errors or you could change ASP.NET settings. Rules which cause these events to be logged can be changed using <system.web><healthMonitoring><rules>. Since you say you're prohibited from writing into the event log I would guess your best bet is to just erase the default rules as explained here:

<healthMonitoring>
  <rules>
    <clear />
  </rules>
</healthMonitoring>

which removes the two default rules each causing writes to event log.

like image 42
sharptooth Avatar answered Sep 22 '22 08:09

sharptooth