Add EventLogTraceListener to Debug.Listener : Debug « Development « C# / CSharp Tutorial






#define DEBUG

using System;
using System.Globalization;
using System.Diagnostics;

class MainClass
{
  public static void Main() 
  {
    TextWriterTraceListener tl = new TextWriterTraceListener("Example21_12.txt");
    Debug.Listeners.Add(tl);
    
    EventLogTraceListener t2 = new EventLogTraceListener("Application");
    Debug.Listeners.Add(t2);

    Debug.WriteLine("Starting Main()");
    Debug.Assert(1 == 2, "1 ==2");

    Debug.WriteLine("Exiting Main()");
    Debug.Flush();
    Debug.Close();
  }
}








14.24.Debug
14.24.1.Debug Assert
14.24.2.Add Console.Out to TextWriterTraceListener
14.24.3.Set up a TraceListener to a file
14.24.4.Add EventLogTraceListener to Debug.Listener
14.24.5.Debug and Trace Output
14.24.6.Using Switches to Control Debug and Trace: BooleanSwitch
14.24.7.Using Switches to Control Debug and Trace: TraceSwitch