-2

We have a Salesforce environment that calls an Azure Cloud from an APEX class. The customer wants to log all the calls that are made and if an error occurred also the error.

How can I create logs from an APEX class that keep logging?

1 Answer 1

3

You can use the event monitoring api for this.

From the docs,

EventLogFile: Represents event log files for event monitoring. The event monitoring product gathers information about your Salesforce org’s operational events...You can interact with event monitoring data by querying fields on the EventLogFile object (like EventType and LogDate).

So, EventType is a field that's important to note because one of the supported Event types is Apex Callout, which "contain details about callouts (external requests) during Apex code execution"

A simple query example with the EventLogFile:

SELECT Id, EventType FROM EventLogFile WHERE EventType = 'Apex Callout'

Keep in mind that logs are there for only 30 days. Obviously, you can persist the data through a custom logging object if you need to keep the data for longer.

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