Library code snippets

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)

Comments

  1. 22 May 2006 at 06:53

    Hi Mehdi Golchin,

    Thanks for you guide. I have successed to configure the aspnet_regsql.

     

    regard,
    Jason

  2. 21 May 2006 at 18:39

    Hi Jason,
    Health monitoring uses SQL Server for storing web events. so you must add health monitoring's tables and stored procedures. for that you have tow solutions. you can use aspnet_regsql command in visual studio command prompt or if you like to create a installation page for your project you can use
    that code which generates health monitoring's tables and stored procedures as run-time.

  3. 21 May 2006 at 15:48

    Dear Mehdi Golchin,

    With regard to your Step 1, can you please explain more in details "run-time mode". As i do not know where to install it Many thanks...

    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)

     
    Regard,
    Jason
  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Health Monitoring in ASP.NET 2.

Leave a comment

Sign in or Join us (it's free).

Related podcasts

Events coming up

  • Mar 15

    DevWeek 2010

    London, United Kingdom

    DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.

Want to stay in touch with what's going on? Follow us on twitter!