Write Trace based on the BooleanSwitch
#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:
Related in same category :
-
-
-
-
-
-
|