This article is not yet ready to enter a substantive stage. First, inserting segments is related to the exception handling part of the entire system.
The most basic principle is, of course, all exceptions that may affect the normal operation of the system.CatchAnd keep a record. The most basic principle can only be grasped at the specific implementation stage. However, when there are always hundreds of thousands of leaksApplication. threadexceptionAndAppdomain. currentdomain. unhandledexceptionThe event is handled as needed.
For exceptions that have already occurred in the above two events, not only must they be recorded, but also Error In the form of dialog box reminder, otherwise the status is unknown. Whether to disable the entire applicationProgramIn principle, the system ignores this vulnerability. There is only one situation: Unhandledexception Event parameters in Isterminating Is True You must close the application. Applicationexit Timely clear some resources in the event.
Of course, exception handling is a big topic. In some cases, an exception should be thrown specially. These things need to be analyzed in detail. Here we will only mention some general practices in the system.
Logging is also an important part. The items to be recorded include some program exceptions, network exceptions, system startup and exit, and some important operations. There is also a large number of received communication commands, a large numberRFIDThe information read by the hardware device. The system has been running steadily and steadily. These items are not useful, but once the system is in good condition, these records will be the basis for solving the problem and troubleshooting.
Log records are determined from various aspects Log4net Now you have to think about how to configure it. Finally, the system uses two Appender , Eventlogappender Used to record exception information, including program and network exceptions. This information is generally not much, and is recorded in EventLog In my opinion, program exceptions are generally defined as" Error "Level, only in Threadexception And Unhandledexception The event is defined as" Fatal ", While the network exception uses" Warn ". Another Appender Yes Rollinglogfileappender Used to record operation information, communication information, and hardware information. This record volume is large and it is necessary to generate a log file in an hour. Info " level.