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
msreekmattmsreekmatt 

Apexdebug log details API

I can get the apex log infirmation from apexlog object

 

SELECT Application, LastModifiedDate, DurationMilliseconds, Location, Id, LogLength, LogUserId, Operation, Request, StartTime, Status, SystemModstamp FROM ApexLog

 

I dont see a column where I can get the details about the log , the information that you see when you click on View link in debug log screen against each debug log item.

 

thanks

 

SForceBeWithYouSForceBeWithYou
The best way to get the body of an ApexLog programmatically is through the Tooling API. 

This is touched on in the Using Tooling REST API section:
http://www.salesforce.com/us/developer/docs/api_toolingpre/Content/intro_rest_overview.htm 

As well as the ApexLog page:
http://www.salesforce.com/us/developer/docs/api_toolingpre/Content/sforce_api_objects_apexlog.htm 

The syntax is GET /sobjects/ApexLog/[id]/Body

You could do something highly not recommended like use this  URL:
https://[prefix].salesforce.com/apexdebug/traceDownload.apexp?id=[apexLogId] 
But then you would have to worry about screen scraping considerations like setting the session ID.

Sorry it took so long for someone to respond...
Best of luck!

Nathan Pepper
http://youtube.com/MayTheSForceBWithYou
@sforcebewithyou
Mihir Shah1Mihir Shah1
Hi NAthan,

I am trying to use get request. GET /sobjects/ApexLog/[id]/Body
But I am not getting desired response.  The error response is "You have attempted to reach a URL that no longer exists on salesforce.com.".

Can you please help here?
SForceBeWithYouSForceBeWithYou

Mihir,

It looks like that's the right format (as shown here: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexlog.htm (https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexlog.htm" target="_blank)).

Make sure you replace "[id]" with the ID of the debug log you're trying to retrieve, for example:

/sobjects/ApexLog/07LR000000gMlE7MAK/Body

Also, make sure you're using API version 28.0 or newer, and make sure the Debug Log has persisted and isn't removed.  ApexLogs made through the Developer Console are captured through User Trace Flags with LogType "DEVELOPER_LOG" and do not persist (I forget the time window... 60 minutes?), whereas ApexLogs that are captured through User Trace Flags with LogType "USER_DEBUG" will persist on the server until deleted.