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".

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

2 Answers 2

3

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.

4
  • 1
    The first point was the problem. I'll add another comment explaining further.
    – Acuariano
    Dec 29, 2014 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, 2015 at 23:38
  • 1
    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. Apr 28, 2017 at 4:24
  • 1
    Facing same issue Jul 26, 2017 at 12:42
0

I think logs are not enabled for REST Apex. I am not able to set trace flag on the REST Resource class. Although the class exists and I am able to select the class for setting the trace, I get following error when I try to save the trace flag.

Trace Flags on REST Apex

1
  • Welcome to Salesforce Stack Exchange (SFSE)! This is a Questions & Answers site, not a threaded forum. Yours seems to be either a comment to go under the Q or the other A, or if you need help a new question (in it, you can link to this question or its other answer for reference if you'd like - just click "Share" at the bottom left of the post to get a URL). Regardless, please read Why and how are some answers deleted?, and be aware that this "answer" will likely be deleted.
    – Moonpie
    Sep 8, 2022 at 13:39

You must log in to answer this question.

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