Csharp/C Sharp by API/System.Diagnostics/TraceSwitch

Материал из .Net Framework эксперт
Версия от 12:13, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

new TraceSwitch

  
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>
*/


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>
*/


TraceSwitch.TraceInfo

  
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>
*/


TraceSwitch.TraceVerbose

  
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>
*/


TraceSwitch.TraceWarning

  
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>
*/