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
ChickenOrBeefChickenOrBeef 

Only some of my CPU Limit debug logs are showing up

Hey everyone,

I've run into the incredibly frustrating "Apex CPU time limit exceeded" error, so I put in debug statements throughout my triggers, in between each class call, which should show the CPU time after each class is called. That should theoretically tell me which class is causing the issue.

The problem is that only some of the debug logs show up.

For example, here is my main opportunity trigger, where all the opportunity classes are called. I have a debug statement after each call:
 
trigger MainTriggerOpportunity on Opportunity (before insert, before update, after insert, after update) {
    
    if(trigger.isBefore){
            
        if(trigger.isInsert){
            
            if(checkRecursive.runBeforeInsertOnce()){
            
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(Trigger.new);
                
               	System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassOppIndustry is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassRenewalDate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassLeadConvertUpdates updater2 = new ClassLeadConvertUpdates();
            updater2.updateLeadConvertFields(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE INSERT: CPU time after ClassLeadConvertUpdates is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
            
        }
        if(trigger.isUpdate){
            
            if(checkRecursive.runBeforeUpdateOnce()){
            
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassOppIndustry is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassRenewalDate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBrandParent updater2 = new ClassBrandParent();
            updater2.addBrandParent(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassBrandParent is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassCallScheduledAdvance updater3 = new ClassCallScheduledAdvance();
            updater3.addCallScheduledDate(Trigger.new,Trigger.oldMap);
                
                System.debug(LoggingLevel.ERROR,'[OPP] BEFORE UPDATE: CPU time after ClassCallScheduledAdvance is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
     }
  }
    
    
    if(trigger.isAfter){
        
        if(trigger.isInsert){
            
            if(checkRecursive.runAfterInsertOnce()){
            
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassRenewalProcess is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppBrandCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppTeamMember updater2 = new ClassOppTeamMember();
            updater2.insertOpp(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppTeamMember is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassPrimaryContactCopy updater4 = new ClassPrimaryContactCopy();
            updater4.copyPrimary(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassPrimaryContactCopy is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppPicklists updater5 = new ClassOppPicklists();
            updater5.updatePicklists(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassOppPicklists is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBDSourceCreate updater6 = new ClassBDSourceCreate();
            updater6.addBDSource(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassBDSourceCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassMapPlatform updater7 = new ClassMapPlatform();
            updater7.copyPlatform(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassMapPlatform is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassAnnualDealRevenue updater8 = new ClassAnnualDealRevenue();
            updater8.addAnnualRevenue(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassAnnualDealRevenue is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDemandGenOpportunity updater9 = new ClassDemandGenOpportunity();
            updater9.addContactRoles(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER INSERT: CPU time after ClassDemandGenOpportunity is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            }
       }
        if(trigger.isUpdate){
            
            if(checkRecursive.runAfterUpdateOnce()){
            
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassRenewalProcess is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassOppBrandCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDrawLoopUpdates updater3 = new ClassDrawLoopUpdates();
            updater3.updateDrawLoopFields(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassDrawLoopUpdates is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassPrimaryContactCopy updater4 = new ClassPrimaryContactCopy();
            updater4.copyPrimary(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassPrimaryContactCopy is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassOppPicklists updater5 = new ClassOppPicklists();
            updater5.updatePicklists(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassOppPicklists is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassBDSourceCreate updater6 = new ClassBDSourceCreate();
            updater6.addBDSource(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassBDSourceCreate is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassMapPlatform updater7 = new ClassMapPlatform();
            updater7.copyPlatform(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassMapPlatform is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassAnnualDealRevenue updater8 = new ClassAnnualDealRevenue();
            updater8.addAnnualRevenue(Trigger.new);
                
                System.debug(LoggingLevel.ERROR,'[OPP] AFTER UPDATE: CPU time after ClassAnnualDealRevenue is ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
            ClassDemandGenOpportunityUpdate updater9 = new ClassDemandGenOpportunityUpdate();
            updater9.addContactRoles(Trigger.new,Trigger.oldMap);
                
       

                
            }
        }
    }
}

But here is the log after I mass updated some opportunities in production:

User-added image

As you can see, only the final debug statements are showing up. Any idea why that would be? Also, if you have any suggestions on how to better find out where the CPU limit error is coming from, that would be extremely appreciated.

Thanks!
-Greg
Cloud_forceCloud_force
i think there is a limit on logs that are seen. CPU time limit error comes when your transaction takes that much time. So it is the overall time taken for execution and not any specific statement that is failing for you. You should probably check for long running Queies or DML's that are taking long time. You can check time taken in logs (left hand side of the logs you can see time)

http://www.forcexplore.com/2014/08/visualforce-and-apex-tutorial-for-beginners.html
You TechoYou Techo
https://mycenturahealth.site/ patient portal offers benefits, medical records, bill payment, messaging feature, reminders, test, reports. We've given you MyCentura login guide here.
You TechoYou Techo
https://mycenturahealth.site (https://paybyplatema.site/) patient portal offers benefits, medical records, bill payment, messaging feature, reminders, test, reports. We've given you MyCentura login guide here.
Mary HirschMary Hirsch
If only some of your CPU limit debug logs are showing up, it could be due to several reasons. Here are some troubleshooting steps you can follow to resolve the issue:
Check the Debug Log Level: Ensure that the debug log level is set to the appropriate level. If it's set too low, it might not capture all the necessary logs. You can increase the log level to capture more logs.
Review the Debug Logs: Go through the debug logs that are showing up and look for any errors or warnings that might be preventing other logs from showing up.
Check the CPU Usage: Check the CPU usage of the system. If the CPU is being used heavily, it might be preventing some of the logs from showing up. You can try freeing up some CPU resources by closing unnecessary applications or processes.
Increase Logging Limits: Check if there are any logging limits set that might be preventing the logs from showing up. You can increase the logging limits to capture more logs.
Check System Resources: Make sure that the system has enough resources to capture and store the logs. If the system is low on memory or storage space, it might not be able to capture all the logs.
Update Debugging Tools: Make sure that you are using the latest version of the debugging tools. Older versions might have bugs or limitations that prevent all logs from showing up.
By following these troubleshooting steps, you should be able to identify and resolve the issue of only some of your CPU limit debug logs showing up. Paybyplatema (https://www.paybyplatema.website/)
Luis LatimerLuis Latimer
If you're experiencing issues where only some of your CPU limit debug logs are showing up, there could be several potential reasons for this. Here are a few troubleshooting steps you can take:

Logging Configuration: Check your logging configuration to ensure that the appropriate log levels and filters are set. It's possible that the CPU limit debug logs are not being captured due to incorrect configuration settings. Adjust the settings if needed to include the desired logs.
Logging Levels: Verify that the CPU limit debug logs are set to an appropriate logging level. If the logs are set to a lower level than the configured threshold, they may not be captured in the log output. Adjust the log level if necessary to ensure the logs are included.
Logging Framework: If you're using a logging framework or library, ensure that it is properly integrated into your application. Double-check that you're using the correct logger instance and that it is correctly configured to capture the CPU limit debug logs.
Code Placement: Verify that the code responsible for generating the CPU limit debug logs is correctly placed in the codebase. Make sure it's executed in the appropriate conditions or at the desired points in your code flow to generate the expected logs.
Runtime Environment: Consider any specific aspects of your runtime environment that could affect the logging behavior. For example, some platforms or frameworks may have specific settings or limitations on log output. Check the documentation or support resources for your specific runtime environment for any relevant information.
Log Storage and Retrieval: Confirm that the logs are being stored and retrieved correctly. If you're using a logging service or system, check its configuration and ensure that you're able to access and view all log entries.

If you have tried these steps and the issue persists, it may be helpful to provide more specific information about your application, logging setup, and any relevant error messages or log configurations. This can assist in diagnosing the problem more accurately and finding a suitable solution.

MyCenturaHealth (https://www.mycenturahealth.vip/)
arthur jonharthur jonh
I believe that the number of logs that can be observed is finite. If your transaction takes too long to process, you will receive an error from the CPU. So it's not that any one statement is failing, but rather the execution time as a whole. If DMLs or Queries are taking a very lengthy time to complete, you should investigate the cause. Time spent can be viewed in logs (on the logs' left-hand side).aim provider portal  (https://www.aimproviderportal.online/)

 
alex c;erkalex c;erk
Through Flyingtogether.Ual.com, the United Airlines personnel can access online company resources. By logging into the Flying Together website, United Airlines employees can access their pay stubs, communicate with management, review their work schedules, and remain current on business news. flying together (https://www.flyingtogether.website/)



 
david pay 3david pay 3
Thank you. Your example didn't work for me but I managed to fix it, which was basically the same thing! PayByPlateMa (https://www.paybyplatema.life/)