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.
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.
After running the query:
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.
000387868

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.