Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debug log (like logcat in Android)?

I'm trying to debug a C#/.Net program in Visual Studio 2010 but it's timing-sensitive so breakpoints mess it up. So I just want to log certain events and their relative times and watch them as my program is running.

Does Visual Studio (or C# or .Net) have any facility for writing to a log file that Visual Studio can display as a debug window?

When I do Android development in Eclipse I can take advantage of their Log class and insert lines that looks like this in my code:

  Log.d("Label1", "Hit checkpoint X");  

And they will appear along with time/date stamps in the LogCat window which is displayed along with other windows in Eclipse.

What's the closest equivalent to this in Visual Studio 2010?

like image 785
user316117 Avatar asked Nov 06 '14 17:11

user316117


1 Answers

You can set a breakpoint that doesn't actually break, but outputs a log message instead. Just set a breakpoint, then right click on the breakpoint and select "When Hit...".

From that dialog select "Print a message" and "continue execution"

Dialog screenshot

like image 111
heavyd Avatar answered Oct 17 '22 13:10

heavyd