473,385 Members | 1,782 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.

Redirect the output of Debug.WriteLine()

Is there anyway to transparently redirect the output of the
Debug.WriteLine statement from the Debug window to something else such
as a console or a file?

Thanks
Nov 17 '05 #1
3 21020

"Frank Rizzo" <no**@none.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Is there anyway to transparently redirect the output of the
Debug.WriteLine statement from the Debug window to something else such as
a console or a file?

Thanks


TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
new TextWriterTraceListener("C:\\debug.txt"),
new TextWriterTraceListener(Console.Out)
};

Debug.Listeners.AddRange(listeners);

Debug.WriteLine("Some Value", "Some Category");
Debug.WriteLine("Some Other Value");

HTH,
Mythran

Nov 17 '05 #2

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...

"Frank Rizzo" <no**@none.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Is there anyway to transparently redirect the output of the
Debug.WriteLine statement from the Debug window to something else such as
a console or a file?

Thanks


TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
new TextWriterTraceListener("C:\\debug.txt"),
new TextWriterTraceListener(Console.Out)
};

Debug.Listeners.AddRange(listeners);

Debug.WriteLine("Some Value", "Some Category");
Debug.WriteLine("Some Other Value");

HTH,
Mythran


Another note, you can create your own class and inherit from the
TraceListener class to add more functionality to the trace listeners. For
example, you could create a SqlTraceListener that would output to a Sql
Server instead of a stream....just a thought :)

HTH,
Mythran

Nov 17 '05 #3
Mythran wrote:

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...

"Frank Rizzo" <no**@none.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Is there anyway to transparently redirect the output of the
Debug.WriteLine statement from the Debug window to something else
such as a console or a file?

Thanks

TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
new TextWriterTraceListener("C:\\debug.txt"),
new TextWriterTraceListener(Console.Out)
};

Debug.Listeners.AddRange(listeners);

Debug.WriteLine("Some Value", "Some Category");
Debug.WriteLine("Some Other Value");

HTH,
Mythran


Another note, you can create your own class and inherit from the
TraceListener class to add more functionality to the trace listeners.
For example, you could create a SqlTraceListener that would output to a
Sql Server instead of a stream....just a thought :)

HTH,
Mythran

That is sweet. Thank you.
Nov 17 '05 #4

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

Similar topics

2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
5
by: chris | last post by:
Hello all - Preface: This isn't a C# Builder question but if you happen to have the answer to my primary problem, please feel free to chime in ;-) I'm using Borland's C# Builder (Personal)...
5
by: MS | last post by:
Here's my simple stored procedure: ALTER PROCEDURE GetMemberIDByEmail @Email EmailAddress, @ID int OUTPUT AS SELECT @ID = ID FROM tbl_Member WHERE Email=@Email RETURN
2
by: Schorschi | last post by:
Ok, I have my own console class that lets me allocate a console, free it, etc. in my windows vb .net application, hell it even hides the cursor, set colors, etc. But the one thing I want to do is...
9
by: David A. Beck | last post by:
When I do a debug.print("blabla") in VB (VS2005) it doesn't show up in the output window, what gives?
0
by: JeffM | last post by:
This seems odd, but it appears that the Page_Unload event is fired twice on a Response.Redirect or a Server.Transfer. The output below demonstrates that during the move from the first to the 2nd...
7
by: Bernard Bourée | last post by:
In order to trace my job I placed some Debug.Writeline in my code but they don't appear in the output window! How to solve it? Thanks Bernard
0
by: shravagiparag | last post by:
Hello, I am developing a console application to invoke gdb session and log in the communication between my application and gdb. I opened gdb as a new process and tried to redirect the input and...
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am using the following command to output my results to the Output window (for testing things out). Console.WriteLine ("Output") I'd like to clear the Output window of any previous output. I...
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: 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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.