How to use Apex Replay Debugger

Step 1. Use the Debug: Toggle Breakpoint and SFDX: Toggle Checkpoint commands to toggle on and off breakpoints and checkpoints, respectively
Step 2.  Use SFDX: Update Checkpoints in Org command to update checkpoint in the org. You must tell Salesforce about your checkpoints so that heap dumps are collected as your Apex code executes
Notes:  You can set as many breakpoints as you like, but you can only set up to five checkpoints at a time.
Be sure to generate debug logs and replay them with Apex Replay Debugger soon after updating your checkpoints, because checkpoints expire after 30 minutes and heap dumps expire after a day.
Step 3. After breakpoints and checkpoints set, run Apex test to generate a replay-enabled debug log.
Use SFDX: Turn On Apex Debug Log for Replay Debugger first. This creates a trace flag to generate replay-enabled debug logs for 30 minutes. You can change the duration in Setup on the Debug Logs page.
Run your apex test class using SFDX: run Apex Tests command.

Step 4. Run SFDX: Get Apex Debug Logs & click on debug log to download.

Step 5. Right-click any line in the debug log, then choose SFDX: Launch Apex Replay Debugger with Current File. After a few seconds, Visual Studio Code opens the Debug sidebar, ready for you to begin stepping through the code.

Published by Sandeep Kumar

He is a Salesforce Certified Application Architect having 11+ years of experience in Salesforce.

Leave a Reply