April 2025 Apex Insider Newsletter
Debug Apex Code Faster by Filtering Debug Logs in VS Code
Debugging code is an essential part of the development process. But if you’ve ever worked with Salesforce’s debug logs, you know they contain huge amounts of information. Finding just the System.debug statements you may have put in your code or just the variable assignment that you are interested in can be a long and tedious task. Fortunately, there are tools to assist you in focusing on just the log lines you want.
Tools for Finding the Needle in the Debug-Log Haystack
Visual Studio Code (VS Code) offers two tools to assist you in finding the information you are looking for within a debug log:
- The first method, which has been around for a while, is the Apex Log Replay Debugger. This is a powerful tool that allows you to replay a debug log one code statement at a time. You could use it to find a certain debug statement or other line of interest in your code, but it takes some setup and training to use effectively.
- The second is brand new and requires no training: the new Output pane text-filter feature. In the default VS Code configuration, Output is one of the selections on the bottom center of the window, while the Filter text box itself is nearer to the bottom right as shown by the highlights in the following screen capture:
How to Use the New VS Code Output Text Filter
Using the text filter is very easy and intuitive. You don’t even have to turn on logging first or set Salesforce to record debug logs beforehand. The filter itself is an unlabeled text box, but hovering over it displays the label “Filter”.
Use the VS Code text filter feature in Output by doing the following:
-
After executing Apex in VS Code, open the Output pane. You should see the results of the execution in that pane.
-
Enter the text you wish to highlight and filter on into the Filter text box. For example, in the image shown in the following screen capture, the word “Exception” is the word in the Filter text box. The drop-down list box to the right of the filter sets itself automatically to “Apex” when you execute Apex code.
You do not need to press Enter. VS Code begins filtering on text as soon as you enter it into the text box. The filter matches the text you entered whether it is a distinct string or part of a larger string. In the following screen capture, observe that the instances of the word “Exception” and “exception” are isolated and highlighted in orange in the debug log, even though the filter entry is “EXCEPTION”. Thus the filtering algorithm is not case-sensitive.
VS Code keeps a record of your entries in the filter for your session. Use the up and down arrow keys while the cursor is in the Filter text box to page through the entries in the filter for that session.
Warren’s Thoughts: TDX25 Connections
I went to TrailblazerDX 2025 (TDX25), the Salesforce conference for Admins and Developers, when it came to the US on March 5 and 6. The best minutes I spent were the ones I spent talking to people. Yes, you can rush from session to session, but I think the real value of the conference is in walking the floors and talking to other attendees. For me, connecting with real people was what TDX25 was all about.
It's especially great meeting Cloud Coders in person. TDX25 got people out of the Zoom window and into real life. I could have grilled them on trigger best practices, but instead I just asked them how to improve the program.
Some shoutouts: I connected with Mike Chandler and we've got some cool stuff cooking up. I also hung out with Saman Attar and got updates on what's new with Camp Apex. And there's always trouble when Chase Brammer and I are together.
First Impressions: Salesforce Deployments using Salto.io
At TDX25, I also made sure to stop by the Salto booth to see Julian Joseph. Julian is my go-to resource for Salesforce DevOps and deployments.
Here is a video with my thoughts on Julian’s DevOps solution, Salto.io:
|
Cloud Coder Wins in March
- Patrick Sees passed the Platform Developer I exam and became an Application Architect!
- Kimberly Belliveau passed the Platform Developer I exam!
- Stephen Church changed his job from being a Salesforce Admin to a Salesforce Engineer!
💡💡💡💡💡💡💡💡💡💡💡💡💡💡💡💡💡💡
Want to be like the Cloud Coders that had big wins in March?
They all got started with the legendary Salesforce Developer 101 course.
Jump in here at cloudcodeacademy.com/101
Already have the 101?
Get the Trigger, SOQL, and Apex Fundamentals course bundle
Responses