ASP.NET Health Monitoring – Building an EventLogWebEventProvider – Part 3
On my previous posts on this health monitoring series I explain to you how and why I made my own EventLogWebEventProvider and which benefits you can achieve by using this provider or by making your own.
Now I'll write about how to use this new provider in one application.
Well, almost everything have been written about this topic and Microsoft has one good article on “How To: Use Health Monitoring in ASP.NET 2.0” so I wont even try to explain all the possible scenarios and configurations, I will simply explain the standard scenario.
Typically I simply want to keep track on two Web Event types:
- the ones related to application errors
- an the others related to application life cycle
As far as I notice there are many people that simply track those from point 1.
Another decision to make is where to store these Web Events data, You do this by choosing a Web Event provider.
ASP.NET give us out-of-the-box several providers and you can make your own provider. Once your provider is done you can use it just like all the others.
In this example I will use the newly created provider.
Now that I know exactly what to track and where to store it I can update my configuration.
All health monitoring configuration data is stored in the system.webhealthMonitoring section and my standard configuration will look like:
<healthMonitoring enabled="true"> <providers> <add name="ExtendedEventLogWebEventProvider" type="NG.Web.Management.EventLogWebEventProvider, NG.Web" source="MyEvtLogSource" /> </providers> <rules> <clear /> <add name="Application Lifetime Events Default" eventName="Application Lifetime Events" provider="ExtendedEventLogWebEventProvider" profile="Default" /> <add name="All Errors Default" eventName="All Errors" provider="ExtendedEventLogWebEventProvider" profile="Default" /> </rules> </healthMonitoring>
Notice the source attribute from the ExtendedEventLogWebEventProvider, using it you can set which EventLog source to use.
Remember that when you create a EventLog source you can choose to create a brand new EventLog and if you choose so, all entries written by this provider in this application context will be isolated from all the others providing one easy way for visual tracking and filtering.
With the health monitoring data in place you should now be able to see the entries appearing in EventLog.