user34537
user34537

Reputation:

Write to console and visual studios output?

In Winform Apps Console.WriteLine() writes to the IDE output tab. In a console app it writes to the console and not to the IDE output tab. For debugging reasons i find it easier if i can have i have a copy of the Console output (ATM i only use stdout) in my IDE. Is there an option to have Console.WriteLine() appear in both?

I use visual studios 2008 & 2010

Upvotes: 1

Views: 675

Answers (2)

R. Martinho Fernandes
R. Martinho Fernandes

Reputation: 234654

You can intercept all output to the stdout by calling Console.SetOut and passing in a TextWriter of yours. From there, the sky is the limit. Or something like that.

But if this kind of message writing starts to get serious I'd suggest using a real logging library like log4net or NLog.

Upvotes: 0

GrayWizardx
GrayWizardx

Reputation: 21241

Possibly the same question as this.

As far as I know you cannot intercept StdIn, StdOut, and StdErr for console windows. You could use one of the options in the above link though (trace debugger, capture output, etc).

Another option might be to use something like log4net to stream to a more convient source only those messages you care about.

Upvotes: 1

Related Questions