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 logs, and you can open them in your IDE. The following screenshot shows how you can retrieve the logs: 

You will see the logs in the sfdx/tools/debug/logs/ folder.

One common misconception is that you need scratch Orgs to work with the Salesforce CLI. However, this is not true and you can use the Salesforce DX CLI to authorize with any Org and some of these functionalities such as tailing logs are available.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.209.131