[CSharp] How many points can this code write to the log?

Source: Internet
Author: User
WriteAppEventLog. cs /**//********************************** **********************************
Created: 2006/03/30
Created: 30: 3: 2006
File ext: cs
Author: xuzhong

Purpose: Write logs to application logs
**************************************** *****************************/

Using System;

Namespace XZSoftware. App. ZhengJun
{
Public class WriteEventLog
{
Public WriteEventLog ()
{
}



Public static int Main (string [] args)
{
Int argsLength = args. Length;
If (argsLength! = 4)
{
Purging ();
Return 1;
}
Else
{
String source = args [0];
String message = args [1];
String type = args [2];
String id = args [3];

Try
{
System. Diagnostics. EventLog. WriteEntry (
Source, message, GetEventType (type), int. Parse (id ));
Return 0;
} Catch
{
Return-1;
}
}
}


Public static System. Diagnostics. EventLogEntryType GetEventType (string type)
{
Switch (type. ToLower ())
{
Case "error ":
Return System. Diagnostics. EventLogEntryType. Error;
Case "warning ":
Return System. Diagnostics. EventLogEntryType. Warning;
Case "failureaudit ":
Return System. Diagnostics. EventLogEntryType. FailureAudit;
Case "information ":
Return System. Diagnostics. EventLogEntryType. Information;
Case "successaudit ":
Return System. Diagnostics. EventLogEntryType. SuccessAudit;
Default:
Return System. Diagnostics. EventLogEntryType. Error;
}
}

Public static void Purging ()
{
Console. WriteLine ("");
Console. WriteLine ("");
Console. writeLine ("************************************* *******************************");
Console. WriteLine ("created: 2006/03/30 ");
Console. WriteLine ("created: 30: 3: 2006 ");
Console. WriteLine ("file ext: cs ");
Console. WriteLine ("author: xuzhong ");
Console. WriteLine ("");
Console. WriteLine ("purpose: Write logs to application logs ");
Console. writeLine ("************************************* ********************************");
Console. WriteLine ("");
Console. WriteLine ("");
Console. WriteLine ("WriteAppEventLog.exe <source> <message> <type> <id> ");
Console. WriteLine ("source: source ");
Console. WriteLine ("message: content information ");
Console. WriteLine ("type: Log type (Error | Warning | Information | SuccessAudit | FailureAudit )");
Console. WriteLine ("id: ID of the error ");
Console. WriteLine ("");
Console. Write ("Sample :");
Console. WriteLine ("WriteAppEventLog.exe \" My_Application \ "\" This is a test. \ "\" Error \ "\" 1000 \"");
}
}
}

Build. batcsc/t: exe *. cs

What can I do?

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.