Troubleshooting, diagnostics and instrumentation is as big a part of the project is as the development of the application itself. Lot of time I have seen projects that do not account for these integral parts of the application development cycle. And when applications run into issue during production, then they do not any means to diagnose the problems quickly and come up with a solution with minimal downtime. In all the projects that I have lead, I put considerable effort in putting lot of diagnostics and health monitoring in place so that when ever there is error in the application we can identify the issue just by looking at log files.
In the past I have used frameworks like log4net and MS Instrumentation ans Logging Blocks to add logging and instrumentation capabilities to ASP.Net applications. Last week while I was researching on a new framework to add logging into an existing application I came across a less known healthMonitoring entry in web.config file of ASP.Net application. When I start digging deep into this I realized that ASP.Net framework already has a very flexible and robust mechanism built into it for logging and instrumentation. I realized that just by adding few entries in web.config file I can get the application to report all unhandled exceptions into a SQL server, Event log or WMI provider. And by writing a custom plugin I can get these to report to my custom repository. Long story short, you really don't need to use any third party plug ins or libraries to add logging capabilities to your ASP.Net applications. Just look at classes offered under System.Web.Management and healthMonitoring entry in web.config file of your ASP.Net applications and you will be able to find lot of information on how to add health monitoring capabilities like logging and instrumentation into your ASP.Net applications.
In next posts and articles I will describe how to use this ASP.Net feature to enable logging and instrumentation for your application and use different providers with it.