Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter output in Visual Studio 2012+?

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?

like image 261
frankish Avatar asked May 13 '15 10:05

frankish


3 Answers

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.

like image 96
FetFrumos Avatar answered Oct 12 '22 13:10

FetFrumos


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.

like image 29
toddmo Avatar answered Oct 12 '22 14:10

toddmo


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.

like image 41
Bogdan Gavril MSFT Avatar answered Oct 12 '22 13:10

Bogdan Gavril MSFT