18

As per Enterprise Messaging Platform in the Summer '17 release notes and First Impressions with Platform Events and the Salesforce Enterprise Messaging Platform I created a simple Platform Event with the API name TestEvent__e and a corresponding trigger.

trigger TestEventTrigger on TestEvent__e (after insert) {
    System.debug('Event Log');

    for (TestEvent__e event : Trigger.New) {
        System.debug('Event: ' + event);
    }
}

Then I ran the following anonymous Apex in the Developer Console:

TestEvent__e testEvent = new TestEvent__e();
List<TestEvent__e> toPublish = new List<TestEvent__e>();
toPublish.add(testEvent);
EventBus.publish(toPublish);

The Developer Console showed the logging for the anonymous apex, but nothing appeared for the trigger subscription to the event.

How do I see debug logging for Platform Event triggers?

  • 1
    Nice Q&A, Daniel! – sfdcfox May 5 '17 at 1:51
  • 3
    @sfdcfox Thanks. In addition to helping others I hope this will assist "Future Daniel" when I wonder why I'm not seeing the expected debug logs. – Daniel Ballinger May 5 '17 at 1:56
26

From Christopher Marzilli via twitter:

when you go into setup to create a new trace you should see an option for "Traced Entity Type" select Automated Process.

It appears that Summer '17 has added a new type of TraceFlag.

enter image description here

To get them to appear in the Developer Console you will also need to uncheck "Show My Current Logs Only". Additionally, it appears that the Streaming API channel that the Developer Console users to monitor for new debug logs won't pickup on the Platform Event Trigger events (or at least it didn't do so consistently for me). So you may need to trigger another log to get it to appear.

From the Platform Events Developer Guide

Debug logs for platform event triggers are created by a process called “Automated Process” and are separate from their corresponding Apex code logs. The debug logs aren’t available in the Developer Console’s Log tab. One exception is Apex tests, which include debug logging for event triggers in the same test execution log. To collect platform event trigger logs, add a trace flag entry for the Automated Process entity in Setup.

  • 2
    Early candidate for best answer of Q2. :) – Adrian Larson May 5 '17 at 13:47
  • Clutch! Its worth noting that these logs only appear in Setup > Debug Logs and not in the Developer Console Logs tab. – Shane Oct 30 '18 at 20:20
  • 2
    @Shane you may need to unchecked "Show My Current Logs Only" as the logs belong to a different user. – Daniel Ballinger Oct 30 '18 at 23:50
  • Oh sweet, then it will be in Dev Console too. Thanks! – Shane Oct 31 '18 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.