Loading

Bulk Delete Trace Flags Through Developer Console Using Tooling API

Publish Date: Jun 2, 2026
Description

Deleting trace flags one by one through the Salesforce UI can be tedious and time-consuming when you have many flags to remove. You can bulk-delete TraceFlag records in Salesforce using the Developer Console's Tooling API query editor, which allows you to select and delete multiple records at once.
Trace flags in Salesforce enable debug logging for specific users, Apex classes, or Apex triggers. Bulk removal is useful when you want to clear all existing trace flags and start fresh, or when trace flags have accumulated over time and are no longer needed.

Resolution

Use the following SOQL query in the Developer Console to retrieve all TraceFlag records:

SELECT Id, CreatedDate, CreatedById, ExpirationDate, TracedEntityId, ApexCode, ApexProfiling, 
Callout, Database, System, Validation, Visualforce, Workflow FROM TraceFlag

mportant: Check the Use Tooling API checkbox in the Developer Console query editor before executing this query. TraceFlag is a Tooling API object and is not accessible via the standard SOQL query editor.

Delete Selected Trace Flags

After running the query:

  1. The results appear in the Query Grid at the bottom of the Developer Console.
  2. Click one or more rows to select trace flags you want to delete. You can select multiple rows.
  3. Click the Delete Row button in the Query Grid toolbar.
  4. Refresh your org and the Debug Logs page to see the changes reflected. The deleted trace flags no longer appear in the UI.

Tips for Targeted Deletion

To narrow down which flags to delete, filter the query in advance. For example, to delete trace flags for a specific user, you can filter by the user's ID using the TracedEntityId field:
SELECT Id, ExpirationDate, TracedEntityId FROM TraceFlag WHERE TracedEntityId = '[UserID]'
The TracedEntityId can be a User ID, Apex Class ID, or Apex Trigger ID.

Knowledge Article Number

000387868

 
Loading
Salesforce Help | Article