473,385 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Trace messages using c#

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.


Jun 13 '07 #1
0 1418

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kevin | last post by:
Hi All, Can someone please tell me what the difference is between DEBUG and TRACE. From what I can see, they are two different classes, but with the same members? Whats the purpose of have two...
5
by: who be dat? | last post by:
Hello all. I'm writing an application that is writing trace information that can be viewed in trace.axd. I would like to rename this and use a different name specific to my application. I know...
1
by: Patrick | last post by:
When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace file, and I can't read the trace file without restarting the IIS: Even the following does NOT work (how could I fix...
1
by: newcomer | last post by:
I have traced action in XML. Now I would like to replay that. How could I do that based on this XML trace? I am using soap:tcp between client and server. thanks,
0
by: McGeeky | last post by:
Hi. I regularly use System.Diagnostics.Trace. I had been using it in a web service with no problems. But when I ran the web service on a different computer I no longer get the trace messages. Trace...
8
by: Bryan | last post by:
Does anyone have an example of an application that can connect to a running process and capture Trace.WriteLine calls like in SQL Server Profiler? I know that we can inherit from a TraceListener...
0
by: Aryan | last post by:
Hi All, My application was working fine and giving me proper trace messages, but now all of sudden it started showing expcetion as "Object reference not set to an instance of an object....
0
by: Blake | last post by:
I am trying to make a trace listener textbox that behaves like the output window in VS, in that it shows trace messages from all trace sources. I created my own listener to write to a textbox...
3
by: Simon | last post by:
Hi all, I'm trying to use the Trace class to log messages to a simple text file. I need to be able to provide a custom filename to be used. I've created a TextWriterTraceListener and added it to...
2
by: Bob S | last post by:
I am using Debug.WriteLine and Trace.WriteLine to output messages from a dll. This dll is used in an application. No matter whether i run the program in release mode or debug mode and whether i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.