TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramalingam S
NA
31
0
Enable TraceLog
Jun 9 2010 3:16 AM
<system.diagnostics>
<switches>
<!-- 0-TRACE_OFF, 1-TRACE_ERROR, 2-TRACE_WARN, 3-TRACE_INFO, 4-TRACE_VERBOSE. -->
<add name="EnableTrace" value="1" />
</switches>
<trace autoflush="true">
<listeners>
<add name="TextListener" type="System.Diagnostics.TextWriterTraceListener" traceOutputOptions="DateTime" initializeData="TraceLog.txt">
</add>
</listeners>
</trace>
</system.diagnostics>
--------------------------------------------------------------------------------------------
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.");
}
}
Reply
Answers (
1
)
OpenRemoteBaseKey throwing an IOException
Calling events