Post-deployment tracing : Trace Listener : Development C# Examples


C# Examples » Development » Trace Listener »

 

Post-deployment tracing









    
#define  TRACE

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

class  MainClass
{
    public  static  void  Main()  
    {
        BooleanSwitch  bsEnableTrace  =  new  BooleanSwitch("TraceOutput",  "Turn  on  tracing");

        TextWriterTraceListener  tl  =  new  TextWriterTraceListener("tract.txt");
        Trace.Listeners.Add(tl);

        EventLogTraceListener  t2  =  new  EventLogTraceListener("Application");
        Trace.Listeners.Add(t2);

        Trace.WriteLineIf(bsEnableTrace.Enabled,"Starting  Main()");

        if  (bsEnableTrace.Enabled)  
        {
            Trace.Assert(  1  ==  2,  "1  ==  2");
        }

        Trace.WriteLineIf(bsEnableTrace.Enabled,  "Exiting  Main()");
        Trace.Flush();
        Trace.Close();
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Trace Listener