Introduction:
It is impossible for any system to run without errors once and for all. The error handling of an excellent system must be excellent, a good programmer will also pay close attention to possible errors and handle fault tolerance accordingly. Try catch in C # saves a lot of trouble for us. This article does not discuss how to handle errors, but provides a collection of error information, and store the error information in Windows logs.
I. Processing code:
Using System;
Using System. Diagnostics;
Using System. Text;
Using System. IO;
Namespace Town. Log
{
/// <Summary>
/// Function: error log class, which records error information in system logs according to the specified event log name
/// </Summary>
Public class Error
{
/// <Summary>
/// Record logs
/// </Summary>
/// <Param name = "sourceName"> Log resource name, for example, Town </param>
/// <Param name = "message"> error message </param>
Public static void Log (string sourceName, string message)
{
EventLog eventLog = null;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.