Error while updating debug log trace flag

I have faced this issue, which I fixed it by deleting all debugs logs from developer console.

  1. In dev console, Select tab "Query Editor" at the bottom of the console
  2. Select check box "Use Tooling API"
  3. Use this query:

    SELECT Id FROM ApexLog
    
  4. Delete all rows (Use shift key to select all rows)

https://help.salesforce.com/articleView?id=000194045&type=1

Once all rows are deleted you will be able to save new debug logs.

Update : Salesforce has released a video tutorial for same. https://youtu.be/rwORE5T39C4


The short term solution is to keep playing whack-a-mole~ApexLog as Pranay has suggested.

Longer term, the problem comes back to the Summer'18 update Store Larger Debug Logs with Changed Log Limits:

We increased the size limit for debug logs from 2 MB per log to 5 MB. You can store up to 250 MB of debug logs at a time. System logs are now deleted automatically after 24 hours instead of after seven days. Monitoring logs are still saved for seven days.

This is also compounded with the Winter '18 update Retain More Debug Logs for Longer:

We changed the way that we delete old debug logs. We now retain debug logs for 7 days. You can generate a total of 250 MB of debug logs in a 15-minute window. When your org is upgraded to Winter ’18, all logs that are at least 7 days old are deleted. This change applies to both Lightning Experience and Salesforce Classic.

Previously, you could generate up to 50 MB of debug logs. We kept them indefinitely, deleting the oldest log each time that you exceeded the limit. We removed the 50 MB limit and changed to a 7-day storage limit.

A couple of releases ago you had Apex logs up to 2 MB in size with a total limit of 50 MB that would automatically drop the older logs.

Currently (Winter '18) you have logs up to 5 MB in size with a total limit of 250 MB that can stay around for up to 7 days before being automatically purged. As many are finding, in a busy org it is easy to hit that 250 MB limit in a much shorter time period than 7 days.

I've created the idea Allow TraceFlags to indicate that Debug logs can be deleted automatically. The idea is to give the developer/admin control how how long they need the corresponding logs to stay around for. With a TTL (Time to Live) setting on each generated log they could be cleared out automatically while still giving the flexibility to capture a few large short term logs or smaller logs with a longer life span.

Nathan Totten is the current PM for this area an is aware of the issues it is causing - https://twitter.com/ntotten/status/1007432141725224960


Note, I've copied this answer out of a duplicate question to here.