Using salesforce CLI, we can list all logs or get specific logs form vs code connected orgs.
Get list of all apex log files sf cli command
Using sf apex list log command to display list of logs with details, like log id, log size, log user, log time and it's duration.
sf apex list log
Get apex log files using salesforce cli
Using this command sf apex get log, we can get last n number of apex log files or If you know the log id, then you can get that log as well.
// get log with log id
sf apex get log -i logID
// if you dont know the specific log id, then get last N number of logs
// if you don't have logs folder in your workspace, then it will create new folder. you can name it anything
sf apex get log -d logs -n 5
Flags:
- -i : apex log id
- -d: log directory, where we need to store the log files
- -n : Latest N number of logs to fetch
Source:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_apex_commands_unified.htm#cli_reference_apex_list_log_unified