Library code snippets
Health Monitoring in ASP.NET 2
- Installing & Configuring
- WebEvents Class
- 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)
Related articles
Related discussion
-
Sheduling and sending mails asp.net
by mr_rajesh86 (0 replies)
-
asp.net add datarow to existing dataset table
by janetb (1 replies)
-
Buy cheap Xanax overnight. Cheap Xanax. Overnight delivery of Xanax in US no prescription needed. Cheapest Xanax.
by asleymar (0 replies)
-
Buy Soma online without a prescription. Soma drug no prescription. How to get Soma prescription. Soma cod accepted.
by asleymar (0 replies)
-
Cheap online order Fioricet. Cheap discount Fioricet. Offshore Fioricet online. How to buy Fioricet online without a prescription.
by asleymar (0 replies)
Related podcasts
-
StackOverflow uses ASP.NET MVC - Jeff Atwood and his technical team
Scott chats with Jeff Atwood of CodingHorror.com and most recently, StackOverflow.com. Jeff and Joel Spolsky and their technical team have created a new class of application using ASP.NET MVC. What works, what doesn't, and how did it all go down?
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.
Hi Mehdi Golchin,
Thanks for you guide. I have successed to configure the aspnet_regsql.
regard,
Jason
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.
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:
This thread is for discussions of Health Monitoring in ASP.NET 2.