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






TraceSource.Switch

  


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.Listeners.Add
3.TraceSource.TraceEvent
4.TraceSource.TraceInformation