Health Monitoring is a framework for monitoring status of running ASP.NET applications and logging significant ASP.NET application events.
Why use Health Monitoring
- Health Monitoring is runtime based for production environment, so it provides information of running ASP.NET applications
- Health Monitoring is customizable, so we can tailor the event information they way we need it.
Examples of Health Monitoring events that can be logged
- Application starts and stops
- Failed logins and unhandled exceptions
- Successful and failed login attempts through Membership
- Successful and failed URL and ACL authorizations by authenticated users
- Valid and expired forms authentication tickets
- View state validation failures
- Configuration errors
- Unhandled exceptions
- Request validation failures
- Anything that causes request to abort
- Requests queued, processing, or rejected
- Process start time and more
Examples of locations where Health Monitoring events can be logged
- Windows event log
- SQL Server database
- Console window using WMI
- Trace output window
What are Health Monitoring events
Health Monitoring events help you keep track of different things that are occurring while your ASP.NET application is running. These events are divided into five main areas:
- Application Lifetime Events
- All Audits
- All Errors
- Request Processing Events
What are Health Monitoring providers
Providers consume Web event data. By default, the ASP.NET health-monitoring system can deliver Web event data using the built-in providers listed in the following table. More than one provider can listen for the same event, and more than one event can be consumed by the same provider.
|EventLogWebEventProvider||Writes Web event data to the Windows event log. By default, this provider is configured to write all errors to the Windows event log. Security operation errors are logged under the event name Failure Audits and logs all other errors are logged under the event name All Errors.
To read event log data, you can view data using the Windows Event Viewer or read event log data programmatically.
|SqlWebEventProvider||Logs Web event data to a Microsoft SQL server database. By default, this provider logs data to the SQL Server Express database in the Web application’s App_Data folder. It does not subscribe to any events by default.|
|WmiWebEventProvider||Passes Web events to WMI, converting them to WMI events. By default, this provider does not subscribe to any events.|
|SimpleMailWebEventProvider and TemplatedMailWebEventProvider||Sends an e-mail message when Web events are raised. By default, these providers are not configured and do not subscribe to any events.|
|TraceWebEventProvider||Passes event data to the ASP.NET page tracing system. By default, this provider is not configured and does not subscribe to any events. Tracing provides the ability to start and stop event tracing sessions, to instrument applications to provide trace events, and to consume trace events. We can use the events to debug an application and perform capacity and performance analysis.|
Configuration settings for Heath Monitoring
There are following 4 sections need to configure to enable Heath Monitoring with asp.net.
(1) <healthMonitoring enabled=”true”>
We need to enable this root not to aware asp.net that we need health monitoring.
In this section we can define the list of events we need to log. We have some default events already available in health monitoring system but if there is need we can define our custom events.
In this section we define the log source where we need to log. We have some default providers already available in health monitoring system but if there is need we can define our custom providers .
This section create the association between event and provider and describe which event should be log with associated log source.