You need to sign in to do that
Don't have an account?

DML is not allowing on ApexLog?
Hello,
I am writting schedulable batch class to delete the apex logs older than one day but on DML statement its giving error "DML operation Delete not allowed on List<ApexLog>". Can we have other way to schedule the same?
Welcome to your suggestions!
Thanks
I am writting schedulable batch class to delete the apex logs older than one day but on DML statement its giving error "DML operation Delete not allowed on List<ApexLog>". Can we have other way to schedule the same?
Welcome to your suggestions!
Thanks
I don't think it can be done via batch class , all you can do is Use Query Editor of Developer Console and Select Use Tooling API and run
'SELECT Id, StartTime, LogUserId, LogLength, Location FROM ApexLog' to delete those logs.
Thanks
Greetings to you!
As mentioned by Meghna, you cannot delete the debug logs in Apex code. You can delete it using Tooling API: https://help.salesforce.com/articleView?id=000333120&type=1
Alternatively, you can use REST to delete debug logs or you can use apex debugger chrome extensions.
Please refer to the below links for more information:
https://salesforce.stackexchange.com/questions/100401/delete-all-in-debug-log
https://salesforce.stackexchange.com/questions/239636/how-to-delete-all-debug-apex-logs-in-apex
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thanks for quick response on the same.
Yes, we can do this from developer console. Still if you find something that meets the requirement you can share.
Thanks!