6

I created a trigger that looks like this:

trigger DG_CM_Trigger on CampaignMember (before insert) {
    System.debug('DG_CM_Trigger - START');
    if (Trigger.isBefore && Trigger.isInsert){
        DG_CampaignMember_Class.populateCustomAttributes(trigger.New);
    }
    System.debug('DG_CM_Trigger - END');
}

As you can see, I have system debug statements at the beginning and end of the trigger. When I look at the debug logs, I can see that the trigger is called...

09:42:46.524 (524616000)|CODE_UNIT_STARTED|[EXTERNAL]|01qc00000004eIV|DG_CM_Trigger on CampaignMember trigger event BeforeInsert for [new]
09:42:46.540 (540035000)|METHOD_ENTRY| [1]|01pc00000006aDT|DG_CampaignMember_Class.DG_CampaignMember_Class()
09:42:46.540 (540101000)|METHOD_EXIT|[1]|DG_CampaignMember_Class
09:42:46.540 (540725000)|METHOD_ENTRY|[4]|01pc00000006aDT|DG_CampaignMember_Class.populateCustomAttributes(LIST<CampaignMember>)
09:42:46.543 (543070000)|CONSTRUCTOR_ENTRY|[114]|01pc00000006aDT|<init>()
09:42:46.543 (543199000)|CONSTRUCTOR_EXIT|[114]|01pc00000006aDT|<init>()
09:42:46.543 (543273000)|METHOD_ENTRY|[114]|01pc00000006aDT|DG_CampaignMember_Class.LeadFieldMapping()
09:42:46.548 (548241000)|METHOD_ENTRY|[41]|01pc00000006aDT|DG_CampaignMember_Class.getCMFieldMapping()
09:42:46.693 (693286000)|METHOD_EXIT|[41]|01pc00000006aDT|DG_CampaignMember_Class.getCMFieldMapping()
09:42:46.703 (703469000)|METHOD_EXIT|[114]|01pc00000006aDT|DG_CampaignMember_Class.LeadFieldMapping()
09:42:46.781 (781457000)|METHOD_EXIT|[4]|01pc00000006aDT|DG_CampaignMember_Class.populateCustomAttributes(LIST<CampaignMember>)
09:42:46.781 (781790000)|CODE_UNIT_FINISHED|DG_CM_Trigger on CampaignMember trigger event BeforeInsert for [new]

However, I do not see my System.debug statement. I had debug statements in the class as well, but does do not show either. I have set the debug log filters to apex code: debug and system: debug (the rest are info). I even tried setting the 'override log filters' on the CampaignMember_Class and also set the levels to apex code: debug and system:debug. I can't seem to figure out why the debug statements are not showing up on the log which is making debugging extremely difficult. Perhaps there is some kind of user setting I'm not aware of? User permissions? (although I'm in the admin profile, but I perhaps something in the profile settings that is not set?) Any help would be appreciated.

2
  • were you ever able to resolve this?
    – Phil B
    May 8, 2014 at 14:38
  • been having a similar issue with print statements not showing up in the log for some classes but not other (there are no log overrides for any classes), very frustrating, I haven't been able to find a workaround yet Sep 3, 2015 at 18:13

5 Answers 5

1

Go to Setup->Monitoring->Debug Logs If your name is not appeared under Monitored user click on New and select yourself as a Monitored user and try again.

3
  • 1
    Thanks for the response. I am already a monitored user. This is where I pulled the log excerpt above. The problem is not getting a log file, the problem is as described above: I do not see the system.debug statements in the log file. Please also note that I've already set my log filters to debug for apex code and system.
    – atlasgp
    Mar 9, 2014 at 2:09
  • When you want to find a code level debug statement in a debug log, you have to search for the key word 'USER_DEBUG'. Not 'System.debug'. Have you tried that?
    – highfive
    Mar 9, 2014 at 2:11
  • Yes, I am aware the debug statements appear as USER_DEBUG in the log. Also, you can see the actual log lines in my post. Notice there no user_debug lines in it. This is not a matter of not knowing how to read the log but rather a matter of the debug statements not showing there at all.
    – atlasgp
    Mar 9, 2014 at 21:13
1

From what I can tell Salesforce selectively removes lines from the debug log to conserve space. You can look for this by searching for something like this in the logs. In other cases there may be a statement towards the bottom that the max debug log size was reached.

*** Skipped 3392766 bytes of detailed log

You can log a case with salesforce to see if they'll increase the size limit on debug log temporarily, are adjusting your logging levels so that the overall debug log size is reduced and salesforce doesn't do it's log trimming. To ensure you have the best chance of seeing your debug logs, set the log levels to DEBUG for APEX, and to ERROR for all other categories.

0

In such cases when, for whatever reason, there is no debug statement on the log I, for debugging purposes, as the ultimate tool throw an exception instead of using System.debug(). Sometimes it's helpful.

trigger DG_CM_Trigger on CampaignMember (before insert) {

    public class DebugException extends Exception {}
    throw new DebugException('DG_CM_Trigger - START');

    System.debug('DG_CM_Trigger - START');
    if (Trigger.isBefore && Trigger.isInsert){
        DG_CampaignMember_Class.populateCustomAttributes(trigger.New);
    }
    System.debug('DG_CM_Trigger - END');
}
0

Most likely, you trigger is not properly compiled since you are not be able to add the System.debug('DG_CM_Trigger - END'); outside of the trigger block.

Try moving that 1 line up and save the trigger. Hope it helps.

Cheers!

3
  • Hi, I'm not sure what you mean about not being able to add the system debug outside of the trigger block. Could you explain?
    – atlasgp
    Mar 9, 2014 at 21:11
  • I also deleted an re-added the trigger, with no success. The funny thing is that I notice other debug statements are showing up from other triggers / classes. So it's my trigger / my class having the issue. I can't for the life of me figure out what is going on. I even tried lowering the version since I noticed the other trigger / class was created in 2013 ( not by me ). Since I see other debug statements, I can rule out profile permissions and log filters. I just don't know what else I should look at. Argh.
    – atlasgp
    Mar 9, 2014 at 21:38
  • 1
    Are you getting a lot of debug output? Do you get something like this at some point (*** Skipped 5969061 bytes of detailed log)? If so, try to lower the level of the debug... Use the developer console and go to Debug -> Change log levels.
    – dangt85
    Mar 10, 2014 at 1:54
0

There are two ways to deal with non-appearing debug logs

1) Sometimes increasing LoggingLevel for your debug statement, e.g. system.debug(LoggingLevel.Error,'my Message'); will help. Set your Debug LogLevel to the same.

2) Setting an explicit Class / Trigger Trace Flag. Please also see this question

Late Answer Reason: Fall into the no-debug issue again myself today, googled it - found this question to be one of the first results.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .