Csharp/C Sharp by API/System.Diagnostics/TraceSwitch
Содержание
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>
*/