SF-PD2 Testing, Debugging, and Deployment Practice Question
A developer wants to log information to the Debug Log for a specific class only, without cluttering the logs for the entire organization. What is the most efficient way to achieve this?
⚠ Common exam trap
Candidates often suggest changing the logging level for the entire organization, which is inefficient and impacts performance, instead of using the targeted Trace Flag feature.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the Debug Logs Setup page to create a Trace Flag for the user/class.
Setting a 'Trace Flag' for a specific user or class is the standard Salesforce tool for targeted logging. This allows developers to isolate log output to their specific testing or debugging activities, preventing the organization's overall log capacity from being consumed by irrelevant system-wide logs. It is a fundamental skill for keeping production and sandbox environments manageable during active development and troubleshooting phases.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set the organization-wide debug log level to 'FINEST'.
Why it's wrong here
Setting the organization-wide log level to 'FINEST' is a catastrophic performance choice. It will generate massive logs for every single transaction in the org, likely hitting storage limits instantly and slowing down the entire platform. Log levels should always be configured at the most restrictive level possible, targeting only specific entities.
- ✓
Use the Debug Logs Setup page to create a Trace Flag for the user/class.
Why this is correct
Trace Flags allow developers to define precise logging levels for specific users, classes, or triggers. This is the official and most efficient way to capture debug information while keeping log output relevant and minimized, which is essential for maintaining a clean and performant development environment for the entire team.
- ✗
Hardcode log level changes in the Apex class constructor.
Why it's wrong here
Apex code cannot control the debug log levels of the platform. Trying to implement this in a constructor is impossible and useless. Debugging configurations are handled at the platform/user level via Setup and Trace Flags, allowing for dynamic configuration without having to modify the actual source code of the application.
- ✗
Use 'System.setLogLevel()' in the Apex code.
Why it's wrong here
There is no 'System.setLogLevel()' method in Apex. Debug log levels are platform-managed settings that are configured outside of the code. Attempting to call non-existent methods will cause a compilation error. Developers must rely on the platform's native debugging tools and Trace Flags to manage log verbosity for their applications.
About these practice questions
One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.