Wednesday 9 November 2011

Health Monitoring for Web application

Logs are important for any application. When application is in production environment and any issue occur, we have to rely on logs because there is no VSTS debugger available in production box.

There are two type of exception, one is handle by application and other one is unhandled exception. Microsoft operation system take care to write unhandled exceptions into event viewer. But some special treatment require for handle exception.

Microsoft has given some best practice for maintaining the log. Please read on more about best practices from MSDN site.

Here I’m going to discuss only two points,

1) During the development , when developer write try…catch block means handle the exception, it is must to write one entry for exception details into log files or event viewer.

2) If Company has selected to write handle exception into Log files, format of error writing must be decided before so when error occurs , using some tools we can find out the exception easily.

I have mention some of the tools for log reader. Log files are huge in term of line and it is really hard to find out the exception/s. LogParser is useful to find out things easily and fast from the log. It used SQL type of query to find out the result.

You can download LogParser from http://visuallogparser.codeplex.com/

Another good option is HealthMonitoring configuration in WEB.CONFIG file to capture errors into event viewer but again all unhandled errors not handled errors.

You can get more inside from the following like for healthMonitoring.

http://blogs.msdn.com/b/erikreitan/archive/2006/05/22/603586.aspx

In simple term, add the following configuration in all web.config file and run the application

  <system.web>

    <healthMonitoring enabled="true">

      <eventMappings>

        <clear />

        <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent"

startEventCode="0" endEventCode="2147483647" />

      </eventMappings>

      <providers>

        <clear />

        <add name="EventLogProvider" type="System.Web.Management.EventLogWebEventProvider" />

      </providers>

      <rules>

        <clear />

        <add name="All Errors Default" eventName="All Errors" provider="EventLogProvider"

profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />

      </rules>

    </healthMonitoring>

  </system.web>

I think this is useful to find out issues on production server or the computer where debugging is not available.

No comments:

Post a Comment