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)
Comments