10

Delete all option in Debug log deletes the log page-wise. Is there any option to delete all the logs in debug at an instance?

10 Answers 10

20

SELECt ID from APEXLOG and run this query in DC Query Editior and select the tooling API checkbox. Now Delete all the records. It will solve your problem and this is a native solution.

10

Use apex debugger chrome extensions. There you can select debug size. for example select 5000 and delete all the debugs. Great tool

Chrome extensions

Apex Debugger

Salesforce Coding Utility

10

I had an org with over 400mb of logs that needed to be cleared! The Salesforce developer tools only lets you delete 2000 rows at a time and the process has to be manually repeated.

So instead I opened up Salesforce classic debug log page and run the following JavaScript from Chrome Developer Tools - it will keep bashing the Delete All button for you.

setInterval(
    function() {
       if (document.querySelector('span[id*="deleteAllStatus.start"]').style.display === 'none') {document.querySelector('input[value="Delete All"]').click()}
    }
    ,250);
  • 1
    This was faster for me than the bulk export. Thanks! – a_sdfc_developer Oct 8 '18 at 23:28
  • Works like a charm. Thanks! – abhi Jun 10 at 14:53
5

I used the dataloader to export and delete all the debug logs. There were over 4K records so this was without a doubt the quickest way to do it. I chose the object ApexLog and used the following query:

SELECT Id, Status, StartTime, LogUser.Name, Operation, DurationMilliseconds, Location, LogLength, Application FROM ApexLog
  • 3
    Just sharing something that helped me. That is the point of the community if I'm not mistaken. If it's not helpful to you feel free to disregard! – Jean Grey Jul 24 '18 at 23:45
  • Thanks Jean, this was by far the quickest solution on this thread. – Brent Thomas Oct 3 '18 at 0:09
3

There is an extension in Google Chrome called the salesforce-tool which helps in deleting all the logs at once. You won't have to click Delete All everytime. It has some other functionalities too.

2

Cross Posting as this question seems more canonical.

You cannot delete the debug logs natively in Apex code. But you can use Rest DELETE endpoint to delete debug logs.

I have created a utility code to delete debug logs that way, you can refer it.

The only limitation is

  1. It can delete only 100 in 1 iteration(You can use composite API to bulkify it).

  2. It creates a new debug log after execution

     List <Apexlog> loglist = [Select Id from Apexlog limit 100];
    for(Apexlog al: loglist){
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(Url.getOrgDomainUrl().toExternalForm()
        + '/services/data/v44.0/sobjects/Apexlog/'+al.Id);
        req.setMethod('DELETE');
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
        HttpResponse res = h.send(req);
        System.debug(res.getStatusCode());
    }
    

If you are calling this method from the lightning component, your Session ID wont be api enabled. Thus you have to use named credentials.

src: https://salesforce.stackexchange.com/a/239642/19118

1

In workbench, query for apex log using below query:

  1. SELECT Id FROM ApexLog
  2. Select view as: Bulk CSV
  3. Download the csv file
  4. Then in workbench go to
  5. Data tab -> select delete option
  6. select From file check box
  7. upload the csv file you got from above mentioned query.
  8. Click on next
  9. click on map fields (id)
  10. click the check box:
  11. Process records asynchronously via Bulk API
  12. Verify that the object type is: ApexLog
  13. Click on confirm delete.
  • This is a easy option than deleting from developer console when there are lot of records to delete. – javanoob Mar 29 at 17:25
0

I've had success using the Bulk API to rapidly remove the existing ApexLog records.

Steps (that are automated):

  1. Use SOQL to Query all the ApexLog records and get back the Ids
    Select Id from Apexlog
  2. If there are few records, currently less than 400, delete them with one or two calls the the Partner API.
  3. Otherwise, with many records, use the Bulk API to delete them by Id.

I needed to automate this as I'd occasionally come across production orgs with tens of thousands of records that needed to be deleted before a new TraceFlag could be created.

enter image description here

This functionality is available (on Windows) in the FuseIT SFDC Explorer. See Button to delete ALL ApexLog's in an org.

0

To delete all the debug log we cab follow these steps

  1. Open the Developer Console.
  2. Select the Query Editor tab near the bottom of the console page.
  3. Select the Use Tooling API check box.
  4. Execute the query - SELECT ID FROM Apexlog.
  5. Query Results will list available rows to be deleted. Use the keys Shift and Arrow Down together to select all rows for deletion.
  6. Click Delete Row.

by using chrome extension we can get button to delete All debug log on single click. Apex Debugger https://chrome.google.com/webstore/detail/apex-debugger/mpckkbblhbfngaininanfjpdfjhbncjo?hl=en

Salesforce Coding Utility https://chrome.google.com/webstore/detail/salesforce-coding-utility/noiijdfibmplbakepjmedfjhfdmghbgf?utm_source=chrome-ntp-icon

0
  1. In Query Editor, SELECT id FROM ApexLog
  2. Click the first row of the list and scroll to the bottom, while pressing shift - click the last row. This will select all the rows.
  3. Click Delete Row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.