Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Console.WriteLine go in ASP.NET?

In a J2EE application (like one running in WebSphere), when I use System.out.println(), my text goes to standard out, which is mapped to a file by the WebSphere admin console.

In an ASP.NET application (like one running in IIS), where does the output of Console.WriteLine() go? The IIS process must have a stdin, stdout and stderr; but is stdout mapped to the Windows version of /dev/null or am I missing a key concept here?

I'm not asking if I should log there (I use log4net), but where does the output go? My best info came from this discussion where they say Console.SetOut() can change the TextWriter, but it still didn't answer the question on what the initial value of the Console is, or how to set it in config/outside of runtime code.

like image 523
Kevin Hakanson Avatar asked Sep 26 '08 03:09

Kevin Hakanson


People also ask

Where does console WriteLine go?

Console. writeline() goes to a console window: the black command / dos prompt.

Where does console WriteLine go C#?

It goes to the console (standard output) or to the stream that the console is set to.

Where does console WriteLine write to in Visual Studio?

WriteLine() does not write to any window in Visual Studio. I guess it will only write to the application console if your application creates a console in the first place, i.e. if it is a console application. You could prefix your message with a string, e.g. ">>>" and use VSColorOutpu to highlight such lines.

Where is the console in Visual Studio?

The console window is unchanged. Press F11 . Visual Studio calls the Console.


1 Answers

If you use System.Diagnostics.Debug.WriteLine(...) instead of Console.WriteLine(), then you can see the results in the Output window of Visual Studio.

like image 176
Greg Bernhardt Avatar answered Oct 02 '22 18:10

Greg Bernhardt