Deleting Old Logs
Jonathan Gillespie edited this page Sep 15, 2021
·
1 revision
Admins can easily delete old logs using 2 methods: list views or Apex batch jobs
Salesforce (still) does not support mass deleting records out-of-the-box. There's been an Idea for 11+ years about it, but it's still not standard functionality. A custom button is available on Log__c
list views to provide mass deletion functionality.
- Admins can select 1 or more
Log__c
records from the list view to choose which logs will be deleted
- The button shows a Visualforce page
LogMassDelete
to confirm that the user wants to delete the records
Two Apex classes are provided out-of-the-box to handle automatically deleting old logs
-
LogBatchPurger
- this batch Apex class will delete anyLog__c
records withLog__c.LogRetentionDate__c <= System.today()
.- By default, this field is populated with "TODAY + 14 DAYS" - the number of days to retain a log can be customized in
LoggerSettings__c
. - Admins can also manually edit this field to change the retention date - or set it to null to prevent the log from being automatically deleted
- By default, this field is populated with "TODAY + 14 DAYS" - the number of days to retain a log can be customized in
-
LogBatchPurgeScheduler
- this schedulable Apex class can be schedule to runLogBatchPurger
on a daily or weekly basis