Event logging made easy in asp.net

To log events/errors in your application, asp.net 2.0 has the healthmonitoring api that lives in System.Diagnostics.

You can get it to log just about anything that happens on your web app. To configure it, it takes you 15 minutes the first time and after that about 2 minutes.

You configure the asp.net services in the sql database.

To run the aspnet scripts on the database : attach the database to sql express via the management studio or something Give it a shorter name.

Then open a command prompt and navigate to %windir%\Microsoft.NET\Framework\v2.xxxxxxx

 

Next run aspnet_regsql – S servername -A all -d dbShortername

 

<
system.web
>

              <
trace


enabled
=


true



requestLimit
=

25



pageOutput
=

false



traceMode
=

SortByTime



localOnly
=

false

/>

              <
healthMonitoring


enabled
=


false

>

                     <
bufferModes
>

                           <
add


name
=


Critical Notification



maxBufferSize
=

100



maxFlushSize
=

20



urgentFlushThreshold
=

1



regularFlushInterval
=

Infinite



urgentFlushInterval
=

00:01:00



maxBufferThreads
=

1

/>

                           <
add


name
=


Constant Monitoring



maxBufferSize
=

1000



maxFlushSize
=

100



urgentFlushThreshold
=

100



regularFlushInterval
=

00:05:00



urgentFlushInterval
=

00:01:00



maxBufferThreads
=

1

/>

                    
bufferModes
>

                     <
providers
>

                           <
add


name
=


MySqlWebEventProvider



type
=

System.Web.Management.SqlWebEventProvider



connectionStringName
=

connectionStringName

                                 
maxEventDetailsLength
=


1073741823



buffer
=

true



bufferMode
=

Constant Monitoring

/>

                           <
add


name
=


CriticalErrorMailProvider



type
=

System.Web.Management.SimpleMailWebEventProvider



from
=


monitoring@sitedomain.com




to
=
“tryit@nospam.com



priority
=

High

                                 
bodyHeader
=


ERROR !!!



bodyFooter
=

Please investigate ASAP



subjectPrefix
=

Problem at [sitename].



maxEventLength
=

4096



maxSize
=

4096



maxMessagesPerNotification
=

1

                                 
buffer
=


true



bufferMode
=

Critical Notification

/>

                    
providers
>

                     <
profiles
>

                           <
add


name
=


siteDefault



minInstances
=

1



maxLimit
=

Infinite



minInterval
=

00:10:00

/>

                    
profiles
>

                     <
rules
>

                           <
add


name
=


All Events Default



eventName
=

All Events



provider
=

MySqlWebEventProvider



profile
=


siteDefault




minInstances
=

1



maxLimit
=

Infinite



minInterval
=

00:01:00



custom
=
“”
/>

                           <
add


name
=


Request Processing Errors



eventName
=

Request Processing Errors



provider
=

CriticalErrorMailProvider



profile
=


siteDefault


/>

                    
rules
>

             
healthMonitoring
>




system.web
>

The same type of functionality exists for asp.net 1.1 and is called elmah. Elmah lives on gotdotnet.



http://www.gotdotnet.com/workspaces/workspace.aspx?id=f18bab11-162c-4267-a46e-72438c38df6f



Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>