using System;
using System.Diagnostics;
namespace nsEventLogs
{
public class LogTrace
{
static public void Main ()
{
EventLog EvLog = new EventLog ();
if (!EventLog.SourceExists ("AppLog.exe"))
{
Console.WriteLine ("Creating event log source");
EventLog.CreateEventSource ("AppLog.exe", "Application");
}
EvLog.Source = "AppLog.exe";
Trace.Listeners.Add (new EventLogTraceListener (EvLog));
Trace.Listeners.Add (new TextWriterTraceListener (Console.Out));
Trace.WriteLine ("Debugging to the event log");
EvLog.Source = "AppLog.exe";
}
}
}