LaceySnr.com - Salesforce Development Posts by Matt Lacey

Getting Back Under the 250MB Apex Log Limit... Quickly*

Posted: 2019-01-22

In the Winter '18 release, Salesforce made changes to the way debug logs are stored, and if you're working with batches, polling or high-volume data it's pretty easy to slam into this limit.

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

Many developers will quickly realise that you can query for the logs in the developer console, and then click rows to delete them. Many of those same developers will have noticed that trying to delete many at once simply doesn't work. Somewhere deep down in the Developer Console JavaScript your browser starts to break down and cry, often followed by the developer doing the same.

I had to go through this process several times before it finally dawned on me there was a simple solution to this problem, and it didn't involve finding a third party tool or browser extension: just order the logs by size!

Select Id, LogLength from ApexLog order by LogLength desc
Debug logs, ordered by size!``

As you can see here, I've got a 1.3MB log sitting at the top of the pile, in another org I was working in recently the first 5 logs alone totalled over 40MB between them. If you've got a few large logs chewing up most of the limit pie then this is an easy way to find and delete them. It'll work in any org and doesn't require any tools. I just hope you've not hit the limit through thousands and thousands of smaller logs.

*if you're lucky!