TraceSource.Listeners.Add : TraceSource « System.Diagnostics « C# / C Sharp by API





TraceSource.Listeners.Add

  


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


public class MainClass
{
    public static void Main()
    {
        TraceSource ts = new TraceSource("MyTraceSource");
        ts.Listeners.Add(new ConsoleTraceListener());
        ts.Switch = new SourceSwitch("mySource");
        ts.Switch.Level = SourceLevels.Error;

        ts.TraceEvent(TraceEventType.Information, 0, "Information event");
        ts.TraceEvent(TraceEventType.Error, 0, "Error event");
    }
}

   
    
  










Related examples in the same category

1.new TraceSource
2.TraceSource.Switch
3.TraceSource.TraceEvent
4.TraceSource.TraceInformation