Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug.WriteLine to different "channel"?

Tags:

c#

debugging

http://i.minus.com/ibsHfIOAy7lBCj.png

I want to write some stuff to VS's output window so I can see what's going on, but it just gets flooded with all this other stuff. Is there some way I can write to a different "channel"? It's got that dropdown there, which I see AnkhSVN has added itself too...can I add another one with only my stuff in there maybe?

like image 921
mpen Avatar asked Sep 25 '11 18:09

mpen


3 Answers

Use Trace for this. You will either have an App.config file or a Web.config file in the project that is running. In this file add a trace listener.

When you call trace, which is very similar to Debug, you can specify the level (Info, Warning, Debug, Error). Based on this level you can decide where and how that information is saved.

How to Trace and Debug in Visual Studio

like image 98
Thomas Coats Avatar answered Oct 24 '22 06:10

Thomas Coats


You can use the "Redirect all Output Window text to the Immediate Window" option:

Redirect Ouput to Immediate

Although it says all, it will only redirect Debug.WriteLine, etc.

Alternatively you can suppress the noisy messages from the output window itself:

enter image description here

like image 33
Rick Sladkey Avatar answered Oct 24 '22 08:10

Rick Sladkey


If you create a visual studio addin (in default) you will have a connect.cs with a public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)

You can use this application object to do what you want to do.

DTE2 app = (DTE2)application;
OutputWindowPane XXX = app.ToolWindows.OutputWindow.OutputWindowPanes.Add("XXX");

Now you can use :

XXX.OutputString("some text" + Environment.NewLine);

And this text will appear in the "channel" called "XXX"

like image 1
Huron Avatar answered Oct 24 '22 07:10

Huron