Use Trace Switch defined in config file : Trace : Development C# Examples


C# Examples » Development » Trace »

 

Use Trace Switch defined in config file









    
using  System;
using  System.Diagnostics;

class  TracingExample
{
    static  void  Main(string[]  args)
    {
        TraceSwitch  MyComponent  =  new  TraceSwitch("MyComponent",  "Application  Switch");

        Trace.WriteLineIf(MyComponent.TraceError,  "MyComponent  -  Error  Tracing  Enabled");
        Trace.WriteLineIf(MyComponent.TraceWarning,  "MyComponent  -  Warning  Tracing  Enabled");
        Trace.WriteLineIf(MyComponent.TraceInfo,  "MyComponent  -  Info  Tracing  Enabled");
        Trace.WriteLineIf(MyComponent.TraceVerbose,  "MyComponent  -  Verbose  Tracing  Enabled");
    }
}


/*
<?xml  version="1.0"  encoding="utf-8"  ?>  
<configuration>
        <system.diagnostics>
                <switches>
                        <add  name="MyComponent"  value="3"  />

                </switches>
        </system.diagnostics>
</configuration>
*/
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Trace