Trace.WriteLine : Trace « System.Diagnostics « C# / C Sharp by API






Trace.WriteLine

  

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";
        }
    }
}

   
    
  








Related examples in the same category

1.Trace.Assert
2.Trace.Listeners
3.Trace.WriteLineIf