Salesforce Developer Console – Getting a stack trace easily

When looking at a particular line in a debug log in the Developer Console, is there an easy way to get the stack trace for that particular line?

I have a CPU Time out issue with my tests and I’ve been playing with the timeline (quite useful for finding which chunks of code are taking up the most time) but I cannot find an easy way to see the stack trace during those times.

I will admit to having fought and failed with the console previously, so there may be a really simple answer which I’ve never come across.


@NSjonas answer is good. I thought I’d add some more options.


It’s not ideal, as you need to modify the code to use it. Try something like:

System.debug(LoggingLevel.Error, new DmlException().getStackTraceString());

Hat tip to @Adrian Larson for the technique for getting the stack trace.


If adding the debug line to the code explicitly is too invasive you could use a Checkpoint. Use the same line of Apex in the checkpoint to dump out the stack trace of interest.

View the entire log as a tree

This is something I’ve been experimenting with recently. It is outside the Developer Console, but the more I use it the more useful I find it.

It does require parsing the entire plain text log and then pairing up events into a tree structure.

What you find in the end it that the nested structure of the event log closely maps the the stack trace. After all, this is what the developer console is doing to recreate the trace you see in the Execution Stack window.

enter image description here

Source : Link , Question Author : Bigears , Answer Author : Community

Leave a Comment