[SOLVED] StackTrace: how to show only my code?


For debugging purposes I store exception’s stack trace to log file in my ASP.NET application. But in most of cases it contains a looot of redundant information: stack trace of ASP.NET’s core before my routines and System calls after.

Is there any way to trim this unrelevant, not in my assembly information from StackTrace object I create from Exception? I’m interested only in chunk of frames inside of whole trace.

Thank you.



One way would be to create a StackTrace object, get the frames from it and loop through them, checking whether each frame was created for a method in one of your assemblies.

I don’t think you really should do this though. You chould rather focus on getting less error messages in your logs than shortening them (which will likely make things more difficult to debug).

Answered By – Matti Virkkunen

Answer Checked By – Clifford M. (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *