Advanced debugging with the Replay Debugger

Salesforce scratch Orgs also offer Apex Replay Debugger for free to do some advanced debugging by setting breakpoints and inspecting variables from the captured logs.

The latest Salesforce extensions for the Visual Studio Code plugin (v 43.0 onward) have the ability to use this feature. The following are the steps to enable this feature:

  1. Turn the debugger on by selecting the Visual Studio command SFDX: Turn On Apex Debug Log for Replay Debugger from the command palette shown in the following screenshot:
  1. The next step is to set breakpoints in the Apex code by clicking on the line number where you want to inspect the values:
  1. Start tailing the logs via the command line by executing the following command:
sfdx force:apex:log:tail -c
  1. Execute the action that triggers the Apex method. In our case, we will click the Search button of the YouTube application.
  2. Retrieve the logs tailed using SFDX: Get Apex Debug Logs... from the Visual Studio code editor command palette:
  1. Left-click on the latest logs collected in the logs folder and click on Launch to replay the Apex debugger. The following screenshot shows how to launch the replay of the debugger with the logs:
  1. Step through using the pane on the top of each line to see the values of the variable. The following screenshot shows how the debug pane on the left parses all the values:

Apex Replay Debugger is a very useful utility for debugging Apex code. Sometimes, downloading logs manually from the Orgs can be time-consuming, so using the Replay Debugger with the IDE helps to download and debug without manually logging to a Salesforce instance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.172.130