Writing to output window of Visual Studio

前端 未结 13 1599
忘了有多久
忘了有多久 2020-11-28 17:56

I am trying to write a message to the output window for debugging purposes. I searched for a function like Java\'s system.out.println(\"\"). I tried Debug

相关标签:
13条回答
  • 2020-11-28 18:10

    The call

    System.Diagnostics.Debug.WriteLine("message");
    

    fails when working with .NET Core (V 1.0 or 1.1).

    We are supposed to create and use a logger from Microsoft.Extensions.Logging, but that log only appears in the dotnet.exe popup console window, not in Visual Studio's Output window.

    0 讨论(0)
  • 2020-11-28 18:17

    Use:

    System.Diagnostics.Debug.WriteLine("your message here");
    
    0 讨论(0)
  • 2020-11-28 18:20
    Debug.WriteLine
    

    is what you're looking for.

    If not, try doing this:

    Menu ToolsOptionsDebugging → uncheck Send Output to Immediate.

    0 讨论(0)
  • 2020-11-28 18:21

    For debugging purposes, the System.Diagnostics.Debug.WriteLine() command will not be compiled into the release version of your code unless you have debug listeners. It writes to all trace listeners which includes the VS output window when running in Debug mode.

    For a Console application. Console.WriteLine() would work but the output would still be generated in the release version of your binary.

    Debug output should also appear in the normal output window when debugging tests; whereas, console.writeline output does not (but can be found in the test output window.)

    0 讨论(0)
  • 2020-11-28 18:22
    Debug.Print("text here")
    

    or

    Console.WriteLine("text here")
    
    0 讨论(0)
  • 2020-11-28 18:25

    This will write to the debug output window:

    using System.Diagnostics;
    
    Debug.WriteLine("Send to debug output.");
    
    0 讨论(0)
提交回复
热议问题