ApexLogs good practices

Do you struggle with too many debug logs?

Go to Developer Console, Query Editor and do the following: 1. Enter SELECT Id, LogLength FROM ApexLog ORDER BY LogLength DESC into input and click “Execute” 2. Select all the logs (logs…

When opening the developer console, this message greets you?

ApexLogs good practices — screenshot 1

There are a few things that can be done!

First, clean up the existing logs:

ApexLogs good practices — screenshot 2

Go to Developer Console, Query Editor and do the following: 1. Enter SELECT Id, LogLength FROM ApexLog ORDER BY LogLength DESC into input and click “Execute” 2. Select all the logs (logs are sorted from biggest to smallest) 3. Click “Delete Row” to remove no longer needed log

Good practices, to prevent it in the future:

1. When setting user trace flags, select only the period you will be using the logs, smaller the better:

Don't do this
ApexLogs good practices — screenshot 3
Do this
ApexLogs good practices — screenshot 4

2. Try to never set logs for Integration users or Test Automation users

3. Remove unnecessary System.debug from the files

Don't do this
HttpResponse response = http.send(request);
System.debug(response.getBody());
System.debug(response.getStatusCode())

4. Use Logger framework or Debugger tools instead of System.debug

Text and code were extracted from the original slide. Plain-text version of the whole catalog