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._
SqlWebEventProvider)

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

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

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.

CREATE PROCEDURE dbo.DM_WebEvent_GetLogEvent AS
    SELECT *
    FROM dbo.aspnet_WebEvent_Events
GO

CREATE PROCEDURE dbo.DM_WebEvent_ClearAllEvent AS
    DELETE
    FROM dbo.aspnet_WebEvent_Events
GO

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

You might also like...

Comments

Contribute

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.

“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” - Bill Gates