First step is to find the logs you want. Downloading all of them is much less efficient. Fortunately that can (usually) solved by a SOQL query on ApexLog object, where the metadata on debug logs is stored.
For my recent use case, it's sufficient to find just the failed transactions, but there are other useful filtering fields in ApexLog such as timestamps and types.
Next comes the actual retrieval of the log text. That needs to be done through Tooling API. The resource URI for REST is /services/data/v39.0/tooling/sobjects/ApexLog/[log Id]/Body/. Log Ids would come from the query in step one. Obviously you can used other compatible API versions as well.
I'm using Workbench as the tool just because it's unbelievably convenient for one-off operations. If downloading is needed for a bunch of logs, some CLI script would probably be needed, which can also enable automated downloading if so desired.
No comments:
Post a Comment