Send output using Console.Write.

B

Boba

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 using the
Console.Write command. The question is how can I see the
outputs in the client machine ? Is there a specific
programm to do it or Can I use the prompt window ?

With thanks,
Boba.
 
J

James

Boba said:
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 using the
Console.Write command. The question is how can I see the
outputs in the client machine ? Is there a specific
programm to do it or Can I use the prompt window ?

With thanks,
Boba.
.

You could take a look at System.Diagnostics.TextWriterTraceListener - it
allows you to dump text to a file. - and can have certain levels set on it.
 
1

100

Hi Boba,
If you want to see your logs on the screen during developing you can make
your project "Console Application" in project's Properties|Output Type.This
will open a console window every time you start the project. In this way all
your Console.WriteLine logs will be visible on the screen. You have to make
your application Windows Application again when you compile the release
version, though. I haven't find a way to set "Console Application" for the
debug and "Windows Application" for the release versions of my projects.
Your Console.WriteLine will stay in the release code, though. So the better
idea I beliave is to use System.Diagnostics.Debug.WriteXXX methods. In this
way you can see your lines in VS.NET's Output|Debug, which is not so
comfortable, I think. The big advantage is that debug code will be in your
code only when you compile the debug versions of the project.
If you dislike (like I do) this Output window you can write and register
your own listener. But what I do actually is to set my project as a "Console
Application" and I put the folowing lines in the begining of my Main
function:
#if(DEBUG)

System.Diagnostics.Debug.Listeners.Add(new
System.Diagnostics.TextWriterTraceListener(Console.Out));

#endif
So, now I can see my output in the console window. All you have to do is to
make sure you return back the Application's output type to "Windows
Application" before the release compilation.

HTH
B/rgds
100
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top