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.

2 Answers 2


If you go to set log panels and select "Execution Stack" and "Execution Log", it should bring up a stack trace panel next to the standard log panel. Clicking any line in the Log Panel will load up the stack for that line.

enter image description here

Another good way to find which areas in your program are slow, is by sorting the "Executed Units" panels by Sum DESC:

enter image description here

If you click on the rows in the "Executed Units" panel, it will filter those in the Log Panel (and then you can click on them there to load them into the "Execution Stack" panel

  • Thank you for your answer, and apologies for my slow reply. Neither of these seem to bring up a Line specific stack trace, which was my ideal. I get a stack tree and an Execution Stack, but not a stack trace. Unless I'm looking in the wrong place?
    – Bigears
    Commented Feb 7, 2017 at 11:49
  • @Bigears You could try a log replay debuggers.... They artificially create a stack trace like what you're looking for, however they are very buggy (i know this because I wrote one of them)
    – NSjonas
    Commented Feb 7, 2017 at 21:09

@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

  • Thank you for the additional information. The specific problem I'm having is an intermittent time-out and I'm unable to know exactly where it is happening. Unfortunately, this means that adding specific stack trace code might not be appropriate here. The parsing might be a good approach. Have you used a particular programme to achieve that?
    – Bigears
    Commented Feb 7, 2017 at 11:53
  • 1
    @Bigears I've put the debug log parsing out in the FuseIT SFDC Explorer. It's free, but Windows only. Commented Feb 7, 2017 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .