Ad Code

How to delete debug logs in salesforce

Delete debug logs in salesforce

An explainer on different ways to delete debug logs in the Salesforce lightning.

Often, we get an alert or notification to delete the debug logs when the available limit is reached. We must delete the logs and reproduce the scenario to collect a new set of logs.

We can delete debug logs using

1.    Debug logs view from the Salesforce setup

2.    Developer console

3.    Workbench

each method discussed in detail below.

1.  Debug logs view

Log in to Salesforce > Navigate to setup > Search for Debug logs in the Quick Find search box

Click Debug Logs

Click the Delete All button

Debug log view in salesforce setup

This view shows only a subset of logs at a time. We have to perform the Delete All operation multiple times if there are hundreds of log entries.

Note: You can only delete monitoring logs from this screen.

SystemLog vs Monitoring Log

For system logs, Location is SystemLog. System logs are generated as part of system log monitoring, such as while you use Developer Console, and are visible only to you.

For monitoring logs, Location is Monitoring. Monitoring logs are generated when your org has active CLASS_TRACING or USER_DEBUG trace flags. These logs are visible to all your organization’s admins.

2.  Developer console

This is an easier way to delete all the logs at a time!

Log in to Salesforce > Navigate to developer console > Click CTRL + SHIFT + O to get the Open Resource popup, Type ApexLog and Double click ApexLog.obj

Salesforce developer console

Select all the columns and click the Query button.

Object query in developer console

Make sure the query is auto-populated in the editor. Click Execute to get the list of logs

Query editor in developer console

If any difficulties in auto-populating the query, use the below one as a reference.

SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds, SystemModstamp, StartTime, Location, RequestIdentifier FROM ApexLog

Apex log entries are retrieved when you click on the Execute button

Developer console apex logs

Select the first record in the list displayed, scroll down to the end, press SHIFT and select the last record. 

Make sure all the records are selected. Click the Delete Row button, and Select Yes in the Confirm Delete dialog. 

Developer console apex logs

That’s it!

Refresh Grid or execute the same query mentioned above to check the status of the deletion.

Quick and Simple, isn’t it?

We can also delete apex logs using the workbench, detailed steps are below.

3.  Workbench

Login to the workbench authorizing the Salesforce instance in which logs are to be deleted.

For Salesforce developer edition and prod, select Production, for other cases select Sandbox as an environment.

Salesforce workbench login screen

If you notice the below error, log in with the latest API version.

Salesforce workbench login error

API version picklist in the login screen is shown below. If there is no error please proceed with the next step.

Salesforce workbench API version

Go to menu item
Queries > Select SOQL Query

Enter the below-mentioned SOQL query in the editor, Select Bulk CSV, and Click the Query button

SELECT Application, DurationMilliseconds, Id, LastModifiedDate, Location, LogLength, LogUserId, Operation, Request, RequestIdentifier, StartTime, Status, SystemModstamp FROM ApexLog

Salesforce workbench query view

Apex logs are retrieved in the CSV. Click the download icon to get the CSV file.

Salesforce workbench Bulk API Job Status

Downloaded CSV is used to delete the apex logs.

Goto menu item Data > Click Delete

Salesforce workbench navigation

Select From File > Choose the file downloaded > Click Next Button

Salesforce workbench delete records

Click Map Fields

Salesforce workbench map csv fields

Choose the options based on your requirement and data size, click Confirm Delete

Salesforce workbench delete apex logs

Records are successfully deleted.

Salesforce workbench record deletion status

Wrap up

We have seen multiple ways to delete the apex log records from Salesforce. Try these and let us know if you face any issues in the comments section below.

Keep the log data backup if required for future reference and be extra cautious when you delete logs in the production which may need for troubleshooting any issues.

We would like to hear if any improvements needed for the content published on this website. Please post your feedback in the contact us section. We appreciate your support, Thank you.

We will discuss another interesting topic in the upcoming blog post.

Until then…



Salesforce documentation

Post a Comment