Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Where does Console.Writeline() go?

In many of my projects I use Console.Writeline(string) to output some debug information, for Windows Applications (as opposed to Console Applications).

Now, I'm sort of curious what happens to this output when there is no console to output to. The fact that no console exists does not cause any errors or throw any exceptions, and Windows generally seems quite happy about this. Are these statements simply ignored if there is no console, or does it affect performance in any way?

Wednesday, February 18, 2004

It goes to the output tab of that little window that also contains the task list. Depending on what you're writing there, you might have to hunt for it because Visual Studio writes its own stuff there, too.

Ron Porter
Wednesday, February 18, 2004

"Now, I'm sort of curious what happens to this output when there is no console to output to."

Generally speaking, it goes nowhere. You could redirect the console somewhere else, so that it went somewhere, but when there's no console window, by default, it's going into a black hole.

Brad Wilson (
Wednesday, February 18, 2004

Which is why it's a better idea to use Trace.WriteLine or Debug.WriteLine for debug output, because you can conveniently redirect those with a config file.

Chris Nahr
Wednesday, February 18, 2004

Brad: So just like an email that never reaches its recipient then. Somewhere out there there's a whole lot of email-messages and Console-output just lying around :)

Chris: Excellent. Seems like a much better idea, I agree. Thanks.

Thursday, February 19, 2004

You could also try log4net.  It's really cool.  Lets you configure your logging levels at runtime, whole bunch of appenders.

etc. etc.

Thursday, February 19, 2004

log4net doesn't have some of the performance penalties associated with Trace.WriteLine either.

John Wilson
Saturday, February 21, 2004

You can redirect Console.WriteLine with Console.SetOut

John Ridout
Sunday, March 14, 2004

*  Recent Topics

*  Fog Creek Home