Skip to content
Salesforce

Logging HTTP Callouts with Timing, Status, and User Details in Salesforce

July 9, 2025

When building integrations in Salesforce, HTTP callouts are a routine task. Whether it’s sending data to external APIs or retrieving information from third-party systems, callouts are everywhere. 

However, one of the biggest challenges developers face is debugging HTTP callouts when something goes wrong. What if you could automatically log: 

  • Who made the callout
  • What endpoint was hit 
  • What data was sent and received 
  • How long the callout took 
  • And whether it failed or succeeded?

This blog post will walk you through creating a reusable logging tool in Salesforce to track every HTTP callout in your org.

Also Read: Getting Started with Salesforce FlexCards: A Beginner’s Guide

What We’re Building

We’ll build a lightweight HTTP logger utility in Apex that:

  • Sends GET/ POST/PATCH/DELETE  requests 
  • Logs request/response metadata 
  • Tracks success/failure
  • Captures user info and callout duration
  • Stores everything in a custom Salesforce object for visibility

This logger will make debugging integrations easier and faster. 

This logger will make debugging integrations easier and faster. 

Logging HTTP Callouts with Timing, Status, and User Details in Salesforce

Step 1: Create a Custom Object for Logging

Create a custom object named Remote_Action_Log__c with the following fields: 

Field Name Type Description 
Timestamp__c DateTime When the log was created 
RequestUrl__c Text API endpoint being called 
Method_Name__c Text HTTP method (GET/POST) 
Request_Body__c Long Text Area Request payload 
Status__c Picklist Success / Failure 
Exception_Message__c Long Text Area Error details (if any) 
Logged_In_User__c​ Text (18)​ Salesforce user name of who triggered call​ 
Response_Status_Code__c Number HTTP status code (e.g., 200, 500) 
Request_Sent_Time__c DateTime When the request was sent 
Response_Received_Time__c DateTime When the response was received 
Request_Duration_Ms__c Text Time in milliseconds 

Step 2: Build a Generic Apex Class for Callouts

Create an Apex class called HttpCallout that will be used by developers to send HTTP requests in a consistent and trackable way. 

Build a Generic Apex Class for Callouts

Step 3: Create the Logging Method

Now let’s write a method to log all the request/response details and user context into our custom object. 

Create the Logging Method

Step 4: Implement the Callout Logic with Logging

Now add the actual callout logic with timing and error handling: 

Implement the Callout Logic with Logging

👨‍💻 How Developers Use It?

Implement the Callout Logic with Logging2

This automatically logs everything — no extra effort required. 

Viewing Logs

To view logs: 

  1. Use Salesforce Inspector or SOQL: 
Use Salesforce Inspector or SOQL: 

2.Filter logs by id,user, method, or status to debug faster. 

3.Click on the record Id to view full details in the Salesforce UI. 

3.Click on the record Id to view full details in the Salesforce UI. 
3.Click on the record Id to view full details in the Salesforce UI. 2

Conclusion

With just a few lines of reusable Apex, you now have a robust logging mechanism for all HTTP callouts in Salesforce. This helps: 

  • Speed up debugging 
  • Improve visibility 
  • Increase integration reliability 
  • Empower developers to find root causes quickly 

Logging isn’t just a nice-to-have — it’s an essential part of building enterprise-grade integrations. 

Keep Reading

Related Articles and Resources

OmniScript Address Autocomplete with Google Places Api
July 8, 2025

OmniScript Address Autocomplete with Google Places Api

In this article we will learn OmniScript Address...

What are Governor Limits in Salesforce?
October 29, 2025

What are Governor Limits in Salesforce?

If you’ve built on Salesforce for even a day, you’ll hit...

How to Call Integration Procedure and Data Mapper from Apex Class?
December 11, 2025

How to Call Integration Procedure and Data Mapper from Apex Class?

One of the most powerful aspects of OmniStudio in...

How to Call an Apex Class from a Data Mapper in OmniStudio?
June 11, 2025

How to Call an Apex Class from a Data Mapper in OmniStudio?

How to Call an Apex Class from a Data Mapper in? ...

How to Train an AI Agent to Troubleshoot OmniScript Failures?
January 21, 2026

How to Train an AI Agent to Troubleshoot OmniScript Failures?

Your OmniScript is running smoothly in production. Users...

How to Pass List/Obj to Integration Procedure from FlexCard?
November 10, 2024

How to Pass List/Obj to Integration Procedure from FlexCard?

Passing Input to a Integration Procedure, the syntax is...