DEBUGLOG / NOTE
APEX
BUILD → DEBUG → LEARN → SHARE
BUILD → DEBUG → LEARN → SHARE
Debugging Apex becomes easier when you stop reading a log from top to bottom and start looking for the transaction story.
Start with the exception
Find the first meaningful exception or failure. Record the class, method and line number before exploring everything around it.
System.debug('Start debugging');
List<Account> accounts = [SELECT Id, Name FROM Account];
Follow the execution path
You can place a screenshot or diagram directly in the article:
import BlogImage from '../../components/BlogImage.astro';
<BlogImage
src="/images/blog/debug-log-example.png"
alt="Example Salesforce debug log"
caption="Example debug log screenshot"
/>
Put the image at public/images/blog/debug-log-example.png.
Follow the execution path
Move backwards from the failing line and follow the data through services, queries and DML.
debugLog rule: Don’t fix only the line that fails. Find the pattern that made it fail.
Check governor limits
Look for repeated queries inside loops, unnecessary DML, or helper methods that hide database work.
APEXDEBUGGINGDEVELOPER