How To Disable .NET Event Log Warnings? - asp.net

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.

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.

Related

Unable to process more than one MB file by ASMX Service

Unable to process more than one MB file by ASMX Service even though the file limit set upto 10 MB. Getting the following exception:
Event code: 3001
Event message: The request has been aborted.
Event time: 10/1/2019 8:58:14 AM
Event time (UTC): 10/1/2019 6:58:14 AM
Event ID: cb5b16e465ee4a0cb4885c8e8fdddfrd
Event sequence: 982
Event occurrence: 35
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/3/ROOT-1-132143473094866215
Trust level: Full
Application Virtual Path: /
Process information:
Process ID: 22352
Process name: w3wp.exe
Exception information:
Exception type: HttpException
Exception message: Request timed out
Thank You.
The reason for the warning is that the execution time exceeds the currently set ASP.NET request execution timeout value.
You need to increase the execution time out value.
set below code in your web.config file:
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
also increase iis site connection time out value.
Open your IIS, right-click on your site name.
Then open property "Manage Web Site".
Then click on "Advanced Settings".
Expand the "Limits" section,you can set your "connection
time out".
after doing changes restart the iis server.

ASP.Net / AppFabric causes 4011 error "An unhandled access exception has occurred."

I am deploying a version of my website which I have developed AppFabric integration into, instead of using the ASP.NET Memory Cache (we're going to load balance a few web servers, so need distributed caching as opposed to local RAM caching).
Locally, I have AppFabric 1.1 installed, and my website communicates with it over 'localhost' (AppFabric installed on the same computer as the website runs out).
<dataCacheClient>
<hosts>
<host name="localhost" cachePort="22233" />
</hosts>
<securityProperties mode="None" protectionLevel="None" />
</dataCacheClient>
When I deploy this site to one of the test servers in our hosting environment (with AppFabric 1.1 also installed locally on that server), the site in IIS immediately fails, in under one second. If I stop IIS and then start it again, and then refresh the page locally, I get the IIS generic "HTTP Error 500.0 - Internal Server Error" in 800ms. This surprised me - I thought the site would be spinning up ASP.NET stuff and not actually running "user code" in that quick of a time.
So all the site's data access has changed to the pattern of, "check AppFabric for object, if it doesn't exist, retrieve from DB & store inside AppFabric" - so it seems
If I deploy a version of the site to the exact same folder, with all of the AppFabric caching changed to use the in-memory ASP.NET cache, then the site loads with no issues, so the problem is 100% related to AppFabric.
There is no exception logged, I simply see the generic "HTTP 500.0 Internal Server Error" message. If I check the Event Viewer then I can see an exception logged:
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 01/12/2017 12:37:19
Event time (UTC): 01/12/2017 12:37:19
Event ID: 84321f68413340daaf0badf122ceed87
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT-3-131566054392620836
Trust level: Full
Application Virtual Path: /
Application Path: ..\..\..\..httpdocs-shared-cache\
Machine name: machine
Process information:
Process ID: 26752
Process name: w3wp.exe
Account name: -
Request information:
Request URL: https://localhost:443/Index.aspx
Request path: /Index.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: -
Custom event details:
There is no stacktrace to show WHERE the failure is occurring.
I have configured AppFabric's security like this (as a test) - and as shown in the web.config, we talk to AppFabric with 'None' for both security mode & protection level.
Set-CacheClusterSecurity -SecurityMode None -ProtectionLevel None
I have hit a brick wall with this and am not sure where else to turn. I tried to install AppFabric 1.0 on the server but it is no longer supported on Windows 2016.
Locally I am using AppFabric 1.1 and am running on Windows 10. As stated, if I deploy the exact same codebase, just with AppFabric communication replaces with .NET memory cache then the site loads okay on the server, which is why I'm convinced it's related to AppFabric.
Does anyone have any pointers as to where I can start to look into this further? I tried
Turns out, ELMAH was catching the exception and still creating the XML log file. This pointed me towards 'Access to the 'global' registry key is denied' - you have to add the application pool user to the 'performance log' and 'performance monitor' user groups.

DisallowRotationOnConfigChange setting does not appear to apply

We have a ASP.NET application running on iis7 with the application pool having "Disable Recycling for Configuration Changes" set to True.
When we make a modification to the web.config however, the app pool still recycles as indicated by the event log:
Event code: 1002
Event message: Application is shutting down. Reason: Configuration changed.
Event time: 4/16/2015 2:34:23 PM
Event time (UTC): 4/16/2015 9:34:23 PM
Event ID: 36792e5493444e7893665e66e4a4415b
Event sequence: 150
Event occurrence: 1
Event detail code: 50004
Application information:
Application domain: /LM/W3SVC/1/ROOT/edudemov9-15-130736932997750186
Trust level: Full
Application Virtual Path: /edudemov9
Application Path: S:\Sites\edudemov9\site\
Machine name: TEHKYLE
Process information:
Process ID: 8820
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Is there any other setting or feature that would override the DisallowRotationOnConfigChange setting?
You can find the answer here: https://serverfault.com/questions/315652/iis7-5-prevent-recycling-when-changing-default-document
"disallowRotationOnConfigChange is for app pool settings only and not for web.config, so an appdomain recycle still occurs even if disallowRotationOnConfigChange is applied. There is a File Change Notification (FCN) registry change that can prevent web.config changes from causing an appdomain recycle, but then the changes themselves won't be picked up either until the app pool is manually recycled..."

Asp.net Event code 3003

My event log has thousands of entries for code 3003 which says "A validation error has occurred.". I am properly handling the validation on server side and error is caught in global.asax and proper message is shown to the user. I don't want to add code to handle the characters on client side by javascript or turning on ValidateRequest=false
My concern is only the event log entries and is there any way I can stop asp.net not to log event 3003 in event log?
Just add:
<pages validateRequest="false" enableEventValidation="false"/>
To your web.config to apply it to the whole site.
Edit:
Goes in the System.web section.

health monitoring to eventlog setting source

I want to setup health monitoring in my asp.net app (using .net 4.5).
In production we will log the health events to a separate database (along with other operational type data).
In development though I'd like to setup to use the event log so there isnt a need to setup the other database when developing.
I have got logging to the event log working however I don't know how I can filter out the event log events only for the ones for my application.
Looking at them an event looks like this
Log Name: Application
Source: ASP.NET 4.0.30319.0
Date: 29/07/2012 8:50:46 PM
Event ID: 1305
Task Category: Web Event
Level: Information
Keywords: Classic
User: N/A
Computer: scorpion
Description:
Event code: 1004
Event message: Application compilation finished.
Event time: 29/07/2012 8:50:46 PM
Event time (UTC): 29/07/2012 10:50:46 AM
Event ID: 41f9c898cda14f7685f5c448f13f806a
Event sequence: 10
Event occurrence: 4
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/5/ROOT-1-129880325799889790
Trust level: Full
Application Virtual Path: /
Application Path: c:\users\pyro\documents\visual studio 2012\Projects\MvcApplication3\MvcApplication3\
Machine name: SCORPION
Process information:
Process ID: 556
Process name: iisexpress.exe
Account name: scorpion\pyro
Custom event details:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="ASP.NET 4.0.30319.0" />
<EventID Qualifiers="16384">1305</EventID>
<Level>4</Level>
<Task>3</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2012-07-29T10:50:46.000000000Z" />
<EventRecordID>6775</EventRecordID>
<Channel>Application</Channel>
<Computer>scorpion</Computer>
<Security />
</System>
<EventData>
<Data>1004</Data>
<Data>Application compilation finished.</Data>
<Data>29/07/2012 8:50:46 PM</Data>
<Data>29/07/2012 10:50:46 AM</Data>
<Data>41f9c898cda14f7685f5c448f13f806a</Data>
<Data>10</Data>
<Data>4</Data>
<Data>0</Data>
<Data>/LM/W3SVC/5/ROOT-1-129880325799889790</Data>
<Data>Full</Data>
<Data>/</Data>
<Data>c:\users\pyro\documents\visual studio 2012\Projects\MvcApplication3\MvcApplication3\</Data>
<Data>SCORPION</Data>
<Data>
</Data>
<Data>556</Data>
<Data>iisexpress.exe</Data>
<Data>scorpion\pyro</Data>
</EventData>
</Event>
The only thing that might be useful is the application domain but it doesn't look like that there is a way to access that through an eventlogentry short of doing some kind of nasty parsing.
Is there something I'm missing here and I could actually set something in the log that would make it easier to filter out ones just for my app, I could look for the asp.net string but that doesn't guarantee its only going to get things directly related to my app.
If it isn't possible to do this without having to rewrite the provider, is there a better provider to use for a throw away kind of development scenario that doesn't require much setup.

Resources