28

I am having problem inspecting specific things in my Debug.WriteLn output in Visual Studio 2015. (Same thing in 2012 and 2013 version too.)

XCode and Eclipse both include a filter-box on top of the Output window. I tried to find a similar extension for Visual Studio but I had no luck. Is there any way to have a similar feature and filter the output window?

1

4 Answers 4

60

I use this method:

Open Debug – Output window, just by right click on the Window.

enter image description here

You can Check / Uncheck as per your need.

1
  • 1
    I am using VS for so many years and didn't know this context menu even existed! Why didn't they put these options into the toolbar? Commented Nov 17, 2023 at 15:56
14

One thing I just found in VS 2017 (and I think it's in other versions too) is:

Tools | Options | Debugging | General > Redirect all Output Window text to the Immediate Window

This gives you just the program's Debug.WriteX output in the immediate window and leaves all that other trash in the output window, which you can leave closed.

I can still go look at the trash in the output window if I need to for some reason; it isn't suppressed. It just doesn't make it into the immediate window.

And I just leave the little immediate window docked at the bottom.

I think it's good because with all the trash coming out in the output window, I really wasn't paying any more attention to the output than I would a terms of use agreement (which is to say, just about none), so the baby was getting thrown out with the bath water. But now I actually see some program debug output that lo and behold, needs attention.

IMHO Microsoft should expand the output window dropdown box to include all the categories that FetFrumos pointed out in his answer, so developers can just leave it set to "Program Output". I think this would be a good improvement.

2
  • 2
    Visual Studio community edition 17.3.0 preview 1.1 June 2022. Ican't get this to work. The redirect is there, I useDebug.Writeline and using System.Diagnostics. Am I doing something wrong?
    – gfmoore
    Commented Jun 12, 2022 at 8:51
  • Note that in VS2022 this will also redirect any caught exception messages.
    – LarryBud
    Commented Jan 16 at 3:39
8

Various services in VS write to the output window so there is an in-built filter based on source. You can often select the source such as "Build Output", "Test discovery", "General", "Debug" etc.

Debug.Write calls are intercepted by VS and the text ends up in the Output window but there is no in built filtering.

I can think of 3 ways around this:

  1. Use DbgView to intercept the Debug.Write messages instead of letting VS intercept them. DbgView has very powerful filtering and coloring features*
  2. Try this extension that colors the output based on regular expressions
  3. Write your own extension (it's not that difficult!)

(*) If you go down this route note that Debug.Write is just a trace and when you attach the VS debugger it will add itself as the trace lister. Same for DbgView. But when you detach it will not remove the listener and the messages will be lost.

4
  • Thank you for your time and reply! I tried DbgView (with administrator privileges) but it doesn't print anything related to my app. (I started and stopped debugger but it didn't work). Coloring extension is useful but not enough for me as it still fills the output window. It is strange that no one needed this feature. I will try to see if I can quickly write an extension (though I don't know how to, yet) :-/
    – frankish
    Commented May 13, 2015 at 13:02
  • 1
    Try to run you app without the debugger (or without VS at all) and then start dbgview. Commented May 13, 2015 at 14:02
  • I kept VS open but stopped debugger, DbgView worked correctly and I am able to filter it to make tests. Thank you very much. (But again, I hope someday VS includes that filtering feature, so I can use VS's debugger dynamically)
    – frankish
    Commented May 13, 2015 at 14:54
  • After 4 years, this feature still does not exist but now I discovered an extension that does what I want from @GrantTheAnt 's answer.
    – frankish
    Commented Aug 22, 2019 at 5:14
7
+500

I've wanted to filter Visual Studio output for many years. Eventually I decided to write an extension to do it. If you're interested, you can check it out at niahtextfilter.com.

Here's an idea of what it does:

Niah Text Filter filtering some debug output

3
  • 6
    This was exactly what I wanted. After 4 years. It is incredible that Microsoft has not included this yet.
    – frankish
    Commented Aug 22, 2019 at 5:14
  • 2
    FYI, the extension is not free. There is a 30-day trial version if you want to try it. Commented Jun 20, 2021 at 8:10
  • 1
    This extension is kind of clunky, but it is worth the money IMO. I've used it to debug projects with a lot of spam in the Output window where the other developers didn't take much care to make the Output window usable for debugging and it was a lifesaver. Commented Jul 13, 2021 at 11:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.