--------------------------------------------------------------------------------------------
public static class Tracer
{
// Enable/Disable Traces based on the Configuration file
// Display Name "EnableTrace" must equivalent to the Switch Name of AppConfig value
private static TraceSwitch appSwitch = new TraceSwitch("EnableTrace", "Switch in config file");
private static bool _enableTrace = false;
public static void TraceIt(string message)
{
switch (appSwitch.Level)
{
case TraceLevel.Off:
break;
case TraceLevel.Verbose:
case TraceLevel.Warning:
case TraceLevel.Error:
case TraceLevel.Info:
_enableTrace = true;
break;
default:
break;
}
if (_enableTrace)
TraceIt((object)message);
}
public static void TraceIt(object obj)
{
Trace.WriteLine(System.DateTime.Now.ToString());
Trace.WriteLine(obj);
Trace.Flush();
}
public static void TraceIt(string p, string p_2)
{
throw new Exception("The method or operation is not implemented.");
}
}
Koteswararao MallisettiPosted Jun 9, 2010, 7:01 AM