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
1trinity1trinity 

Debug logging when using Sites

Hi,

 

I have a simple Site object which uses a Visualforce page, which uses an apex controller class. In this controller class, I put some debug statements (System.debug), but I am finding that the output is not being written to the log. I know for a fact that the code is being executed because other calculations in that class are executing.

 

Is there a reason why my debug statements are not printing just because I am calling the code from a Site? I have used System.debug in other areas where I just have a Visualforce page and an Apex class and the debug worked fine...

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
1trinity1trinity

Hi, thanks for your help - that worked. When I went to Debug Logs, to my surprise there was a user for every Site object I had. The name of the user was "Site Guest User, Name of Site" and when I selected the one for my site the logs showed up.

 

Thanks!

Mara

All Answers

HaagenHaagen

Hi 1trinity,

 

I don't have a solution for you. But my thinking is that you might be running the site as another / anonymous user? 

 

Try using the UserInfo object to print the userid somewhere and check if was acctually your user. I would be surprised if debug logging did not work with sites. 


Cheers!

 

Martin

sjain1.2523113033806995E12sjain1.2523113033806995E12

Hi,

      To track the code through debug log in sites, for this you can give  the guest user in debug log directly go to setup-> administrative permisison-> Monitoring-> debug log-> select Guest Uesr to debug for sites.

 

1trinity1trinity

Hi, thanks for your help - that worked. When I went to Debug Logs, to my surprise there was a user for every Site object I had. The name of the user was "Site Guest User, Name of Site" and when I selected the one for my site the logs showed up.

 

Thanks!

Mara

This was selected as the best answer
buzzboldstevebuzzboldsteve

Post WInter '17, you may need to set a cookie for your requests, even after you have selected the Guest User for debug logging:

https://releasenotes.docs.salesforce.com/en-us/winter17/release-notes/rn_forcecom_debugging_guest_user.htm