3

I'm not able to see any System.debug(); calls from my Apex class in my debug logs, which is being called via JavaScript Remoting in a Visualforce page.

Client Portal APEX Controller (@RemoteAction method is the one I'm calling with the debug statement):

public class ClientPortalHomeController {
    public Contact contact {get; private set;}

    public ClientPortalHomeController() {
        contact = [
            Select Id, FirstName, LastName, Birthdate
            From Contact
            Where Id In (Select ContactId From User Where Id = :UserInfo.getUserId())
        ];
    }

    @RemoteAction
    public static String UserIDLookup(String handle) {
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://jsonplaceholder.typicode.com/posts/1');
        request.setMethod('GET');

        Http http = new Http();
        HttpResponse response = http.send(request);
        System.debug(LoggingLevel.INFO , response);
        return response.getBody();
    }

}

Debug Logs page in Setup: debug logs not showing up

I even changed the APEX field to Debug as shown in this answer.


How it's being fired:

Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.ClientPortalHomeController.UserIDLookup}',
    igHandle,
    function(json,event) {
        var res = $('<div/>').html(json).text();
        res = JSON.parse(res);
        console.log(res);
    }
)

Additional debug level screenshots:

debug levels

debug level description

9
  • My only advice is to doublecheck the Name that you're debugging on. is the RemoteAction definitely firing? Nov 16, 2016 at 18:39
  • How are you performing the action on the page? Is it through a public Site or community? Nov 16, 2016 at 18:42
  • Added how it's being fired in the post. And yes it's definitely being fired because I'm getting info back in the developer's console.
    – qarthandso
    Nov 16, 2016 at 18:48
  • Just added more screenshots. Do those help?
    – qarthandso
    Nov 16, 2016 at 18:54
  • 1
    @AdrianLarson - It is for sure. I have several orgs where no debug logs are ever displayed on the Setup UI debug logs page despite an active trace but they show up in dev console....Logging is buggy lately it seems
    – Eric
    Nov 16, 2016 at 19:25

1 Answer 1

4

I just tried with a @RemoteAction I had lying around in my developer org. I can't remember what the intention was, but it will serve for demo purposes.

Controller:

@RemoteAction
public static String saveVideo(String data) {
    System.debug(LoggingLevel.INFO,'saving ' + data);
    return JSON.serialize(data);
}

Visualforce Page:

<input type="button" value="Inject!" onclick="sendJson();"/> 

<div id="target" style="border: 1px solid grey; height: 50px;"></div>

<script type="text/javascript">

    function sendJson() {

        var inputJson = {key:'value4',key2:'value5'};       
       Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TestPageController.saveVideo}', JSON.stringify(inputJson) , function(result, event){
            if (event.status) {
                //Existing div
                document.getElementById('target').innerHTML = result;

            }
        },{escape: false});
    }
</script>

This produced a debug log with the VFRemoting Operation type.

VFRemoting log

The INFO log entry

Note that this log appeared in the older Debug Logs UI without having the developer console open.

I tried dropping the ApexCode level back to INFO and it still worked.


Things to try/check:

  1. Are there any "Class and Trigger Trace Overrides" configured for ClientPortalHomeController. These would override any general logging levels.
  2. Are you getting any logs from other actions, such as loading the Visualforce page?
  3. Are you getting exceptions back from the Remote action due to an error in the callout - see Debugging JavaScript Remoting
  4. Does the UserIDLookup static method work if you call it via anonymous Apex?
  5. Double check that the Debug log expiration date is in the future.
4
  • 1
    Great answer. Just be aware there are orgs out there where NO logs are written to the setup debug log UI regardless of the Stack Trace set. I have ran into this in several orgs lately. Have not been able to find a common thread though except one but do not know if that is the cause of the issue or just happens to be the org profile I have been in lately.
    – Eric
    Nov 16, 2016 at 20:45
  • @Eric That would certainly spoil your day. Although getting no logs might be easier to work with than intermittent logs when it comes time to raise a support case. Nov 16, 2016 at 20:53
  • Already tried that. Closed - Please see developer forums. Partner community, no help this time alas, case still closed. Interested to see the OP's resolution though
    – Eric
    Nov 16, 2016 at 20:55
  • @Eric if/when it happens again let me know and I'll try and help escalate it if required. Nov 16, 2016 at 21:18

You must log in to answer this question.

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