Logger in .net

C#:

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace LoggerCS
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
if (!EventLog.Exists("Application""Dragon-PC"))
            {
                EventSourceCreationData esc 
= new EventSourceCreationData("JoeyDemo""Application");
                esc.MachineName 
= "Dragon-PC";
                EventLog.CreateEventSource(esc);
            }
            EventLog el 
= new EventLog("Application""Dragon-PC""JoeyDemo");
            el.WriteEntry(
"Event Written to Application Log", EventLogEntryType.Information, 234, Convert.ToInt16(3));
        }
    }
}

VB.NET:

 

Imports System.Diagnostics

Module Module1

    
Sub Main()
        
If Not EventLog.Exists("Application""Dragon-PC"Then
            
Dim esc As EventSourceCreationData = New EventSourceCreationData("JoeyDemo""Application")
            esc.MachineName 
= "Dragon-PC"
            EventLog.CreateEventSource(esc)
        
End If
        
Dim el As EventLog = New EventLog("Application""Dragon-PC""JoeyDemo")
        el.WriteEntry(
"Event Written To Application Log", EventLogEntryType.Information, 234CType(3Short))
    
End Sub

End Module

 

posted @ 2009-06-16 10:56  N/A2011  阅读(268)  评论(0编辑  收藏  举报