+ Start a Discussion
Ken Koellner 1Ken Koellner 1 

Debug Log for non-Browser (Twillo) accessing Site

I'm trying to get debug logs when a non-browser (Twillio) access VF pages implemented on Sites (that are coded to deliver XML).  I'm not getting debug logs.  I did some searching and found release notes from Winter '17 that say for sites guest users, a cookie must be set in order to get debug logs.  That works fineina browser.  I tried setting a cookie the controller constructor (see below) that delivers the page but that didn't work.  Maybe because Twillio isn't sending the cookie back.  And even if that might work, the call that came in would not yet have the cookie so I wouldn't have a debug log.

  I haven't figured out a work around.  I'm wondering if anyone else has.
Cookie debugCookie = ApexPages.currentPage().getCookies().get('debug_logs');
        if (debugCookie == null) {
            debugCookie = new Cookie('debug_logs','debug_logs','.force.com',300,true);
        }
        ApexPages.currentPage().setCookies(new Cookie[]{debugCookie});

 
Ken Koellner 1Ken Koellner 1
I should emphasize that I have no problem setting the trace flags for the site guest user and get debug logs when I send requests from the browser.  It's only from Twillio that I'm trying to figure out a work-around to get Apex Debug Logs.

Here's the winter '17 article -- https://releasenotes.docs.salesforce.com/en-us/winter17/release-notes/rn_forcecom_debugging_guest_user.htm
 
Ken Koellner 1Ken Koellner 1
I found this in the Apex manual on the Cookie class -- The setCookies method adds the prefix “apex__” to the cookie names.

So I suspect that what I tried won't work as it's creating a cookie named 'apex__debug_logs'.  I don't know if there is any way to turn that offf.  Also, even it it did work, until the caller (Trillio) gets the correct cookie, there will be no debug log so if it did work, I'd only get debug logs on subsequent requests.
Asif Ali MAsif Ali M
You can try other option to enable the logs for the specific controller class.
Go to Apex Controller in salesforce and click the Trace Logs tab and create a new debug log entry and then start watching the logs