Thursday, December 22, 2016

How to generate Debug Logs for Guest Users || Changes done in Winter'17 Release


Recently while working on public sites, I have noticed that debug logs are not getting generated for guest users in the same way it was used to work earlier. Debug log is always handy while working in Salesforce. It will help you to debug the problems, help you to understand the flow etc.

So while debug log was not getting generated, it became so difficult for me to debug the issues. After few hours of searching in Google, I have realized that in Winter'17 release, Salesforce changed the way of debug log generation for Guest Users. By "Guest User" I wanted to mean users having Guest User License.

The reason behind the change is - Public sites are getting used by many users(Guest Users). So setting up a debug log for Guest sUer may generate multiple debug logs which will quickly fill up the debug log. 

After Winter'17 release, Salesforce made some changes and due to that debug logs will be generated only for those targeted users. But what will differentiate those target users from the all other users using that public sites? Good questions. Answer to the question is that debug log will only be generated for those Guest users using the browser which has a special cookie

Really is it "Cookie"? Yes, now cookie will decide whether the debug log will be generated or not. 

Ok, the next question is how can I set that special "Cookie" in my browser? The answer is also very simple and below are the steps you need to follow -


  • Open the site in your browser. [Note - I am using Google Chrome, but any browser will work].
  • Open the Chrome DevTools console by right clicking in the page and opening the "inspect" section. 
  • Execute the below command to set the cookie -
  1. If the domain is .force.com domain, paste the below command in the console and execute - document.cookie="debug_logs=debug_logs;domain=.force.com";
  2. If you use the custom domain(say yourCustomDomain.com), paste the below command in the console and execute - document.cookie="debug_logs=debug_logs;domain=yourCustomDomain.com";
This new feature is available in both Lightning Experience and Salesforce Classic.
I hope this post will help you while debugging your public sites.
Please post your feedback. Thanks.

0 comments:

Post a Comment