Delete All Debug Logs in Salesforce.

It will be sooner or later; we will need to delete the logs because of reaching limitation. There are several ways to do so besides using Debug Logs Page (Setup->Environments->Logs->Debug Logs).

Using the Developer Console:

we can use the Query Editor of Developer Console to query all the Debug Logs then select all the logs and press delete rows button.

Select Id,LogLength from ApexLog

Using SFDX:

When we are reaching the limits of the Debugs, There is no way we are using the Developer Console anymore. Because with the DC, the records are deleted one by one, this will cause the DC to hang. We will need to use BULK API to delete all the logs.

Query all apex logs and exports the logs into a CSV file.

sfdx force:data:soql:query -q "Select id from ApexLog" -r csv > apexlog.csv

Delete all the logs in bulk.

sfdx force:data:bulk:delete -s ApexLog -f apexlog.csv

Note: If you are using Windows, do not use Powershell to generate the CSV file, use cmd instead. Powershell generates randoms hidden characters which can cause stateMessage: InvalidBatch

Using Workbench:

Navigate to queries -> SOQL Query:

Select Bulk CSV and Input “Select id from ApexLog” to query Box then click Query.

Then download the CSV file by clicking on “download completed batch results” icon under Batches.

Once you have the csv file: Navigate to data->delete. Then select from file, choose the downloaded file and click next.

Click on Map Fields

Select Process records asynchronously via Bulk API and choose Object Type : ApexLog then click Confirm Delete. Done

No Comments Yet.

Leave a comment