A developer wants to view real-time debug log streaming in their local environment using the Salesforce CLI. Which command should the developer execute?
Trap 1: sf apex run test
Executing `sf apex run test` initiates the execution of Apex unit tests rather than tailing system logs, making it unsuitable for capturing real-time log output during manual debugging or application usage. This command is tempting because developers frequently use Salesforce CLI tools during local troubleshooting sessions, and it represents a primary mechanism for running automated test suites and retrieving test execution summaries from the command line. It would be the correct choice when a developer needs to validate code coverage or verify that a specific set of unit tests passes successfully within an org.
Trap 2: sf project deploy start
Pushing local source files and metadata changes directly to an active scratch org or sandbox is the primary function of this command, making it tempting for developers working entirely within a terminal-based IDE workflow. However, it fails in this scenario because it manages deployments rather than establishing a persistent, real-time subscriber connection to listen for and stream server-side execution logs. A developer would correctly execute this command when they need to synchronise newly written Apex classes or custom objects from their local machine to a Salesforce environment.
Trap 3: sf org display
This command simply outputs authentication and connection details for a target Salesforce organisation, such as the username, instance URL, and access token, making it tempting for a developer who needs to verify their current CLI login state before running terminal operations. However, it fails in this scenario because it interacts exclusively with connection metadata rather than establishing a live telemetry subscription. To stream debug logs in real time to a local environment, the developer must execute the `sf apex tail log` command instead.
- A
sf apex run test
Why it fails: Executing `sf apex run test` initiates the execution of Apex unit tests rather than tailing system logs, making it unsuitable for capturing real-time log output during manual debugging or application usage. This command is tempting because developers frequently use Salesforce CLI tools during local troubleshooting sessions, and it represents a primary mechanism for running automated test suites and retrieving test execution summaries from the command line. It would be the correct choice when a developer needs to validate code coverage or verify that a specific set of unit tests passes successfully within an org.
- B
sf project deploy start
Why it fails: Pushing local source files and metadata changes directly to an active scratch org or sandbox is the primary function of this command, making it tempting for developers working entirely within a terminal-based IDE workflow. However, it fails in this scenario because it manages deployments rather than establishing a persistent, real-time subscriber connection to listen for and stream server-side execution logs. A developer would correctly execute this command when they need to synchronise newly written Apex classes or custom objects from their local machine to a Salesforce environment.
- C
sf org display
Why it fails: This command simply outputs authentication and connection details for a target Salesforce organisation, such as the username, instance URL, and access token, making it tempting for a developer who needs to verify their current CLI login state before running terminal operations. However, it fails in this scenario because it interacts exclusively with connection metadata rather than establishing a live telemetry subscription. To stream debug logs in real time to a local environment, the developer must execute the `sf apex tail log` command instead.
- D
sf apex log tail
Executing `sf apex log tail` directly satisfies the requirement for real-time debug log streaming within a local development environment via the Salesforce CLI. This command opens a persistent connection to the Streaming API using the Tooling REST API, continuously fetching and outputting log entries to the terminal as they are generated on the platform. It eliminates the need to manually query or download logs after execution, enabling rapid local troubleshooting and developer feedback loops without relying on the browser-based Setup UI.