简体   繁体   中英

How to find which code outputs certain debug string in Visual Studio?

Is there a way to find out which piece of code does certain prints in the Output window in Visual Studio?

I have very large project which outputs bunch of small prints repeatedly in thousands. It might take days to find where is it because it doesn't have a constant string to do a simple text search in code. It seems the output is dynamic (like a property name)..

And it is real-time app. Really difficult to debug cos its just goes haywire if you pause it for a second..

Any way it can be done (other than eyeballing 1000s of debug statements)?

I'm assuming that your app is generating these prints using System.Diagnostics.Debug or .Trace calls. In that case you can write a TraceListener and add it to the Debug.Listeners collection. You then have your own handler for the prints and can likely filter your dynamic output (or set a conditional breakpoint). If that's not sufficient you can use System.Diagnostics.StackTrace within your handler to print calling functions real-time.

You can try my Runtime Flow tool (30-day trial). Set filter to include your code and the debug output method, start monitoring and capture debug output calls, search for your certain debug string as the parameter to the debug output method in the Flow window, see what calls this output method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM