function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fred13Fred13 

Debug Trace Flags Automatically Created

This week I started receiving errors that "Your Salesforce org reached the debug log generation limit"  It seems that Trace Flags are being automatically created under my name.  I've searched the help and can only find how to manually create a trace flag.   It does seem that this may be happening whenever batch processess are run.  

I'm just unsure of how to stop them if they are automatically being triggered by code.  THe other thing that is puzzling is that we have not changed anything this week.
Any help would be greatly appreciate!! thanks!!!

Fred
v varaprasadv varaprasad
Hi,

Try like below : 


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

Please check once below links also:

https://developer.salesforce.com/forums/?id=906F0000000BHnjIAG

Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For  Support: varaprasad4sfdc@gmail.com
Blog : http://salesforceprasad.blogspot.com/
 
Fred13Fred13
Thanks Varaprasad.  That is what I have been doing to resolve the issue. However, this keeps happening and it does not seem reasonaable that I have to keep deleting them.   This just started this week.  thanks!
v varaprasadv varaprasad
Hi Fred,

Create one batch class and schedule it. every day or based on hours also.

Sample code : 
 
Global class BatchMassDeleteRecs Implements Database.batchable<sobject>{
     global final string query = 'SELECt ID from APEXLOG';
        
     global Database.QueryLocator start(Database.BatchableContext BC){

      return Database.getQueryLocator('query');
     }
     global  void execute(Database.BatchableContext BC,List<SObject> scope){
         delete scope;
    
    }
    global void finish(Database.BatchableContext BC){
    }

 }



Hope this helps you!

Thanks
Varaprasad
@For  Support: varaprasad4sfdc@gmail.com
Blog : http://salesforceprasad.blogspot.com/


 
Fred13Fred13
I appreciate your help!!  I am still unsure of why this is happening, specifically, because it had not been an issue prior to this week.  thanks again!
SamHowleSamHowle
Hi @Fred13 - I know it's been awhile but I noticed this happening to me as well. This happened specifically when I logged in as another User and started making updates / running a batch. So it may be the case that if you use the "Login as" feature as an Admin then a debug log might be automatically created for the time period that you're logged in.