Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Denis.

like image 666
Denis Avatar asked Oct 28 '25 18:10

Denis


1 Answers

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).

like image 126
Matti Virkkunen Avatar answered Oct 31 '25 08:10

Matti Virkkunen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!