2

I have the following class:

@RestResource(urlMapping='/myservice')
global with sharing class MyService {

    @HttpPost
    global static String newMessage() {
        RestRequest req = RestContext.request;
        System.debug(LoggingLevel.ERROR, 'MyService.newMessage body:\n ' + req.requestBody);
        return 'Testing... 1,2,3';
    }
}

I can't find the debug statement anywhere. I tried adding my user to the debug logs monitored users and tried using the Developer Console. I tried everything mentioned here: Debug not working? I know the class is running because I tested the service and I get the response "Testing... 1,2,3".

  • can you post logs here ?Are logs not registered at all ? – Mohith Shrivastava Dec 28 '14 at 6:54
  • did you find any solution to this issue? Even I am facing the same issue. – Ataullah Khan Nov 15 '16 at 16:14
2

Following are the steps i would take to solve this issue:

  1. Sometimes the web-services are invoked by user-accounts dedicated to Integration or Web-Services. If that is true, did you try to add that user in Debug Logs?

  2. Check the the "Log Filters" for the Web-Service class.

  3. Try using System.debug() without 'LoggingLevel' Option.

  4. Its possible to miss debug logs , if there are so many debug logs generated in short period of time. Salesforce can Only hold up-to 20 request at any given time. Open Developer console before you invoke the service. Salesforce automatically refreshes the console. By this way, there are less chance to miss the Debug Log.

If you tried all the above steps and still fail to get debug logs , i would try to send a APEX email (Just for the heck of it). This is just to narrow down the issue and figure out if the issue is really with Debug Logs.

  • 1
    The first point was the problem. I'll add another comment explaining further. – Acuariano Dec 29 '14 at 20:49
  • In this case, the service was accessed through a Site, which runs with it's own user. Checking how you access the service is a good idea also. When in doubt, try calling the service directly through Developer Console and if the debug works there. – Acuariano Jan 6 '15 at 23:38
  • A little late to the party but I tried your solution. I added the site guest user to the debug log but it still wont print out the logs. I even cleared the log records. Any idea what is going on. – codeinprogress Apr 28 '17 at 4:24
  • Facing same issue – Shanker Paudel Jul 26 '17 at 12:42

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.