TraceSwitch.TraceError : TraceSwitch « System.Diagnostics « C# / C Sharp by API






TraceSwitch.TraceError

  
using System;
using System.Diagnostics;

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

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

  }
}


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

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

   
    
  








Related examples in the same category

1.new TraceSwitch
2.TraceSwitch.TraceInfo
3.TraceSwitch.TraceVerbose
4.TraceSwitch.TraceWarning