Original address: Http://aspnet.4guysfromrolla.com/articles/031407-1.aspx
Author: Scott Mitchell
Before a program is deployed, there are many important phases of software engineering that are defined, such as requirements analysis, design, coding, and testing. However, this is not to say that once the program is deployed and used, it is disconnected from all phases of software engineering. No matter how good the design of a Web application is, how good the code is, how good the test is, it always has a time to drop the chain. If the database server falls off the line, the Web site has more load than you expect from experience, or your Web server itself is having problems with hardware. Unless your program is lightweight or written by God, it will always pop up some questions.
To detect and diagnose these problems, a very important step is to monitor Web programs and log logs. There are a lot of open-source software and Microsoft libraries that can help you record unhandled exceptions and notify developers. How to record unhandled exceptions can be reviewed in human response to unhandled exceptions-handling unhandled exceptions.
ASP.net 1.x does not include any embedded log and notification systems, so developers need to write some code or do some configuration. However, ASP.net 2.0 provides an embedded "health monitoring" tool that you can easily and quickly configure to log events from your Web site to event logs, databases, WMI, email, or asp.net page tracking systems. In addition, the health monitoring system is designed using the provider design pattern (Translator Note: You can look at the article I wrote in asp.net 2.0 to implement the provider design pattern), so that we can implement our own log logic.
This is the first of a series of articles on the health monitoring system of ASP.net 2.0. Here we will learn the basics of a health monitoring system and how to build a health monitoring system to record the log to a SQL Server database. Keep looking down and you'll know more!
Health Monitoring System Overview
asp.net 2.0 's health monitoring system is used to monitor the operating conditions of ASP.net programs in the operating environment. It can log event information to a specified log source. For example, it can record the start and stop of a program, the success and failure of a login, unhandled exception information, and a log source such as a Windows event log or a SQL Server database. It is very easy to configure a health monitoring system by adding some configuration information to the Web.config to specify the event monitor and the log source to send to.
Although the. NET 2.0 Framework provides some built-in health monitoring events and log sources, you do not need to change these things when you need to add custom events or replace them with another log source. You can create a new event by extending the WebBaseEvent class to create a custom log source by extending the Webeventprovider class. Health monitoring systems can be used in design mode and allow you to add custom events and custom log sources to your programs by making changes to the configuration information.
In the future of this series of articles, we will explore how to create custom events and custom log sources. In this article, we will use only the embedded event and log sources to do the example.