Salesforce CLI Command Reference
Release Notes
Deprecation Policy
apex get log
apex get test
apex list log
apex run
apex run test
apex tail log
Fetch the specified log or given number of most recent logs from the org.
To get the IDs for your debug logs, run “sf apex log list”. Executing this command without flags returns the most recent log.
force:apex:log:get
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
‑‑api‑version | N/A | Type: Value Override the api version used for api requests made by this command |
‑‑flags‑dir | N/A | Type: Value Import flag values from a directory. |
‑‑json | N/A | Type: Boolean Format output as json. |
‑‑log‑id | ‑i | Type: Value ID of the specific log to display. |
‑‑number | ‑n | Type: Value Number of the most recent logs to display. |
‑‑output‑dir | ‑d | Type: Value Directory for saving the log files. The location can be an absolute path or relative to the current working directory. The default is the current directory. |
‑‑target‑org | ‑o | Type: Value Required Username or alias of the target org. Not required if the target-org configuration variable is already set. |
Fetch the log in your default org using an ID:
1sf apex get log --log-id <log id>Fetch the log in the org with the specified username using an ID:
1sf apex get log --log-id <log id> --target-org me@my.orgFetch the two most recent logs in your default org:
1sf apex get log --number 2Similar to previous example, but save the two log files in the specified directory:
1sf apex get log --output-dir /Users/sfdxUser/logs --number 2