Create TraceSource and SourceSwitch : TraceSource : Development C# Examples


C# Examples » Development » TraceSource »

 

Create TraceSource and SourceSwitch









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




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» TraceSource