Console.Writeline Does Not Show Up in Output Window

Console.WriteLine does not show up in Output window

If you intend to use this output in production, then use the Trace class members. This makes the code portable, you can wire up different types of listeners and output to the console window, debug window, log file, or whatever else you like.

If this is just some temporary debugging code that you're using to verify that certain code is being executed or has the correct values, then use the Debug class as Zach suggests.

If you absolutely must use the console, then you can attach a console in the program's Main method.

Console.WriteLine does not output to Output Window in VS 2017

VS 2017 ( Community ) does not have "Hosting Process" as in VS 2015.
In VS 2015 the "Hosting Process" can be enabled in the Debug panel of the Project Properties.
With the "Hosting Process" is possible to output to Output Window ( when launching a Release config with Start Debugging ) using Console.WriteLine().
In VS 2017 there is no such enabler and so the Console.WriteLine() does not output to Output Window anymore.

Discovered that (System.Diagnostics.)Trace.WriteLine(Format(...)) outputs to Output Window in Release configs and can replace (System.)Console.WriteLine.

Why doesn't Console.Writeline, Console.Write work in Visual Studio Express?

Console.WriteLine writes your output to the console window opened by your application (think black window with white text that appears when you open the Command Prompt.) Try System.Diagnostics.Debug.WriteLine instead.

Console writeline does not work

The Console.WriteLine isn't for IDE output window. It writes to console. So, you could use Debug.WriteLine() which is available in System.Diagnostics

Debug.WriteLine shows up only in Output window and not Console window

Has been explained in the Microsoft Docs in the TraceListeners collection topic

You can use TextWriterTraceListener and specify the System.Console.Out as the stream where you want to write (or any other suitable stream instance)

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

or just use ConsoleTraceListener.

ConsoleTraceListener trc = new ConsoleTraceListener();
Debug.Listeners.Add(trc);

Another option is to use a pragma directive to overcome the NET Core problem

public static void DebugWriteConsole(string s)
{
#if DEBUG
Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss | ") + s);
#endif
Debug.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss | ") + s);
if (Log.logger != null)
{
Log.Info(s);
}
}


Related Topics



Leave a reply



Submit