+ Start a Discussion
Ken Koellner 7Ken Koellner 7 

How to get Debug Log Body with SOAP Tooling API?

We have an existing testing utility that uses the Tooling API.  It is written using the SOAP version, not the REST version.  I know I can query for the latest log for the user.  I know there is a REST API to get the debug log body.  But, I'd rather not have to recode using REST or mix REST/SOAP if I don't have to. 

I tried the example below.  The getDebuggingInfo() call returns null.  If I got that back, I could call getDebugLog() on that to get the body.  The comments at the end are simply notes of where I would start if I wanted to mix in REST.
com.sforce.soap.tooling.LogInfo[] logList = new com.sforce.soap.tooling.LogInfo[1];
        logList[0] = new com.sforce.soap.tooling.LogInfo();
        ExecuteAnonymousResult apexResult = conn.executeAnonymous ("System.debug('Hello.');");
        com.sforce.soap.tooling.DebuggingInfo_element debuggingInfo = conn.getDebuggingInfo();
        com.sforce.soap.tooling.GetUserInfoResult userResult = conn.getUserInfo();
        String userId = userResult.getUserId();
        // SELECT Id FROM ApexLog WHERE LogUserId = userId ORDER BY LastModifiedDate DESC LIMIT 1
        // /services/data/v49.0/sobjects/ApexLog/07L4p00000FU34uEAD/Body

Below is the output --
[ExecuteAnonymousResult  column='-1'


Anyone know a way to get the Debug Log body with SOAP?  Or am I going to have to mix in a REST request?  Or maybe the flags aren't set properly to get the log and that's why getDebuggingInfo is returning null?
ShirishaShirisha (Salesforce Developers) 
Hi Ken,


Have you checked the below thread which has sample code to get the debug logs using SOAP.


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Ken Koellner 7Ken Koellner 7
The programmer was using Apex to call back to the Tooling API as a Remote Site.  I'm using Java.  But it looks like the result is the same.
Note that comment--
This was partially successful. The CALLOUT_RESPONSE did have a <soapenv:Header><DebuggingInfo><debugLog> in the response. However, this wasn't populated into the DebuggingInfo property in Apex.
The issue I'm gettng is getDebuggingInfo() returned null.  If you look at the raw soap, it's likely as the other programmer said in the above comment.

I found some much older posts with some info on it but they were out of date.  I wonder is SF just simply removed that capability in the SOAP API many releases ago.

So, thanks for the response but it doesn't move any closer to an solution.