Silly Dev Trick: How to delete the apex debug logs with Use Tooling API

Every year they seem to up the limit but for those doing intensive testing and running up your logs here is a quick way to release the storage:

tl;dr

  • Run the following soql in developer console with the ‘Tooling API’ checked:
    • select id, LogLength, LogUser.Name from apexlog order by LogLength DESC

Long Explanation

You get the following error message:

Having an active trace flag triggers debug logging. You have 1076 MB of the maximum 1000 MB of debug logs. Before you can edit trace flags, delete some debug logs.

Reference: https://help.salesforce.com/articleView?id=code_debug_log_delete.htm&type=5

  • Fire up the developer console
  • Click the ‘Query’ tab and check the ‘Use Tooling API’ on/true
  • Copy/Paste the following soql and hit ‘Execute’
    • select id, LogLength, LogUser.Name from apexlog order by LogLength DESC
  • Select a bunch of the top records using the shift key and then click the ‘Delete Row’ button to delete
  • Now wait…and then hit the ‘Refresh Grid’ button a couple times. If you try to delete a row that has already been selected to be deleted it will throw an error window for EACH record…ouch. So have patience if you are deleting the files in chunks. Once you have deleted refresh the entire window and the logs tab will once again work.

Leave a Reply

Your email address will not be published. Required fields are marked *