How to Track Apex Class Activity in Developer Console?

When developing on the Salesforce platform, Apex classes are the backbone of much of the custom logic you implement. Whether you're building triggers, controllers, or batch jobs, understanding what your Apex classes are doing at runtime is essential. Fortunately, Salesforce provides the Developer Console, a powerful built-in tool to monitor and debug Apex class activity. In this blog, we’ll walk you through how to effectively track Apex class activity using the Developer Console.

Why Track Apex Class Activity?

Tracking Apex class activity is crucial for several reasons:

  • Debugging: Helps identify issues in logic, exceptions, or unexpected behavior.

  • Performance Optimization: Analyze CPU time, SOQL queries, DML operations, and heap size usage.

  • Testing: Monitor how classes behave during unit test runs or in response to user actions.

  • Governance: Ensure that the code adheres to Salesforce governor limits.

salesforce developer training


Opening the Developer Console

To begin tracking Apex activity, you need to open the Developer Console:

  1. Log in to Salesforce.

  2. Click on your avatar in the top-right corner.

  3. Select Developer Console from the dropdown menu.

Once opened, you’re ready to begin monitoring Apex activity.

Tracking Apex Class Execution

You can track Apex class activity in real-time using the Logs and Execution Overview tabs. Here's how:

1. Execute Anonymous Block

If you want to test a specific Apex class or method:

  • Go to Debug > Open Execute Anonymous Window.

  • Enter your Apex code, such as:

    apex
    MyCustomClass.doSomething();
  • Check the Open Log option.

  • Click Execute.

Salesforce will run the code and open the execution log automatically.

2. View Debug Logs

To track activity initiated by a user or system process:

  • Go to Debug > Change Log Levels to set appropriate logging levels (Apex Code, Apex Profiling, Database, etc.).

  • Perform the action (e.g., save a record, run a test).

  • Go to Logs > View to see recent logs.

  • Double-click a log file to analyze it.

Analyzing the Log File

Once you open a log, use the following features to track Apex class activity:

A. Execution Overview Panel

  • Visual summary of what happened during the transaction.

  • Tracks events like SOQL queries, DML statements, method calls, and governor limits.

B. Execution Log Tab

  • Step-by-step list of operations.

  • Look for:

    • CODE_UNIT_STARTED – Indicates the start of an Apex class.

    • METHOD_ENTRY and METHOD_EXIT – Show method calls and returns.

    • SOQL_EXECUTE_BEGIN – When a query starts.

    • DML_BEGIN – When a DML operation starts.

C. Stack Tree

  • Hierarchical view of method calls.

  • Helpful in understanding which methods call which, and in what order.

Pro Tips for Better Tracking

  • Use System.debug Statements: Add System.debug('Message') inside your classes to print custom logs.

  • Set Filtered Log Levels: Adjust log levels temporarily to focus on Apex Code and Database for better clarity.

  • Use Checkpoints: Place checkpoints in the code (via Developer Console) to inspect variable states at runtime.

Common Use Cases

  • Track Trigger Execution: Monitor which trigger events fired and in what order.

  • Analyze Batch Apex: View the lifecycle and chunks processed by a batch job.

  • Debug Controllers: Track user actions in Visualforce or Lightning that call Apex controllers.

Final Thoughts

The Developer Console is an indispensable tool for every Salesforce developer. Salesforce developer training is the best way to learn deep concepts to crack such issues. Whether you’re building new functionality or debugging an existing feature, being able to track Apex class activity in real time can save you hours of frustration. With a bit of practice, you'll be navigating logs, setting breakpoints, and optimizing performance like a pro.

So next time something doesn’t work as expected, open the Developer Console—and let the Apex class tracking begin!

Comments

Popular posts from this blog

How Much Does a Salesforce Certification Cost in 2025?

Salesforce Developers Training: Shaping the Future of the AI Era

Transforming Customer Support with Salesforce Live Agent: Real-Time Engagement Made Easy