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));
}
}
}
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, 234, CType(3, Short))
End Sub
End Module
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, 234, CType(3, Short))
End Sub
End Module