Health Monitoring in ASP.NET 2

Page 1 of 3
  1. Installing & Configuring
  2. WebEvents Class
  3. Event Class

Installing & Configuring

Health monitoring is useful to administrators who need to monitor an application and be notified when a critical error occurs, or to developers who need to add instrumentation to a mis-behaving application.

Step 1 : Installing Web Event
You can do this easily in run-time mode with this code below:

Management.SqlServices.Install("Computer Name", "SQL user name",_
"SQL password", "Database name", Management.SqlFeatures._

Step 2 : Configuring Health Monitoring
Write these elements in web.config file:

    <add name="ConnectionString" connectionString="Data Source=(local);_
Initial Catalog=DeveloperMeeting;
UId=sa; Pwd=sa"/>
<healthMonitoring enabled="true">
        <add name="SqlWebEventProvider"
type="System.Web.Management.SqlWebEventProvider, System.Web, Version=, Culture=neutral,
connectionStringName="ConnectionString" maxEventDetailsLength="1073741823" buffer="false"/>
        <add name="Application Lifetime Events Rule" eventName="All Events"
provider="SqlWebEventProvider" profile="Critical" />

You must set health monitoring's provider. you have three selections.
1- SqlWebEventProvider
2- EventLogWebEventProvider
3- MailWebEventProvider

Item one uses SQL Server for storing events and item two uses windows event log.
I would like to use "SqlWebEventProvider" in this article.

Via rules you can tell to web event whether All Events or Failure Audits stores.

Step 3 : Getting events from data store
For this step we must write two simple stored procedures for getting data and cleaning data from data store.

    SELECT *
    FROM dbo.aspnet_WebEvent_Events

CREATE PROCEDURE dbo.DM_WebEvent_ClearAllEvent AS
    FROM dbo.aspnet_WebEvent_Events

And two VB.NET classes for managing event log.(I used my SQL Data Provider VB.NET Class)

You might also like...



Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”