PC Review


Reply
Thread Tools Rate Thread

Trace messages using c#

 
 
=?Utf-8?B?YWtz?=
Guest
Posts: n/a
 
      13th Jun 2007
I've configured Trace switch in my app.config file:
DebugLevel = new TraceSwitch("DebugLevel", "Trace Level for Entire
Application");

and have created and initialized a trace listener in my application code:
FileStream m_Stream = new FileStream(m_logFile, FileMode.Append,
FileAccess.Write);
myTextListener = new TextWriterTraceListener(m_Stream);
Trace.Listeners.Add(myTextListener);

usage in my code:
Trace.WriteLine(DebugLevel.TraceInfo, String.Format("{0} Trace Level={1}",
DateTime.Now, DebugLevel.Level));

output in the log file:
6/13/2007 10:34:49 AM Trace Level=Verbose: True

format of the output I would like to see:
6/13/2007 10:34:49 AM Trace Level=Verbose
(don't want to see any ": True" or ":False" appended to each msg)

The ": True" or ": False" go away if I re-write my code as:
Trace.WriteLine(DateTime.Now, DebugLevel.TraceInfo);
However, I would like to use the String.Format("{0} Trace Level={1}", .....)
as it is very handy with multiple variables to be written to a log file.

Can anyone help me get rid of this ": True" or ": False" in the Trace msgs
in my logfile ?

Thanks in advance.




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding my messages to the trace.axd trace? =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= Microsoft ASP .NET 3 6th Apr 2007 08:10 PM
Trace Messages Within ASP.NET Pages (Issue) =?Utf-8?B?TmF0aGFu?= Microsoft VB .NET 0 24th May 2006 02:56 PM
No trace messages using Diagnostics.Trace McGeeky Microsoft ASP .NET 0 1st Feb 2006 03:49 PM
Is it possible to trace source of messages bearing Netsky.R or .Q? Richard Price Anti-Virus 13 4th Jul 2005 08:52 PM
Trace: Can anyone suggest a good tool to catch trace messages? Rukmal Fernando Microsoft C# .NET 4 27th Oct 2003 10:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 AM.