Using the Salesforce CLI to stream logs

The Salesforce CLI provides the option to stream logs directly from the command line. To tail the logs, you can execute the following command in the command-line window:

sfdx force:apex:log:tail -c

You can also filter the result set from the logs using the GREP Unix command. Let's say you want to only see the USER_DEBUG results, then the command to the filter will be as follows:

sfdx force:apex:log:tail --color | grep USER_DEBUG

In our case, we can add system.debug to the response from the HTTP call and execute the application to stream logs on the CLI. The following screenshot shows the logs captured from the tail command:

Also, note the Visual Studio code editor extension for sfdx can capture these ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.