How to Enable Actuator’s HttpTrace in Spring Boot 3

In this tutorial, you will learn how to enable the Actuator’s httpTrace endpoint in Spring Boot 3. In fact, /httptrace has been renamed to /httpexchanges, so this tutorial will teach you how to enable the Actuator’s /httpexchanges API endpoint instead of /httptrace.

The httpexchanges endpoint provides information about HTTP request-response exchanges. These HTTP exchanges are essentially requests and responses between a client and a server.

With the /httpexchanges actuator endpoint, you can retrieve information about the exchanges that have occurred, such as the HTTP method used, the status code returned, the request and response headers, and the request and response bodies. You can also replay previous exchanges or modify them to simulate different scenarios. To learn more, check out the documentation page.

Step 1. Add Actuator Dependency

The first step is to add actuator dependency to your project.

Maven Dependency

If your project is maven-based, then add the following dependency to pom.xml file.


Gradle Dependency

If your project is Gradle-based, add the following dependency to your build.gradle file.

ependencies {
    compile 'org.springframework.boot:spring-boot-starter-actuator'

Step 2. Enable /actuator/httpexchanges Endpoint

By default, the /actuator/httpexchanges endpoint is disabled in Spring Boot 3. To enable it, you will need to add the following to your file:


To enable all API endpoints, use the following property value instead:


Step 3. Create InMemoryHttpExchangeRepository Bean

For the HttpExchanges API endpoint to work in Spring Boot 3, create a Bean of HttpExchangeRepository type. To do that, add to your project the following Configuration class.

import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository;
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class ActuatorHttpExchangesConfiguration {
    public HttpExchangeRepository httpTraceRepository()
        return new InMemoryHttpExchangeRepository();

The HttpExchangeRepository interface is part of Spring Boot’s HTTP tracing support, which allows you to record and store information about HTTP exchanges that occur in your application. The InMemoryHttpExchangeRepository is a default implementation of this interface that stores the recorded HTTP exchanges in memory.

By creating a HttpExchangeRepository bean and configuring it with the InMemoryHttpExchangeRepository, you enable Spring Boot to record and store information about HTTP exchanges that occur in your application. This information can then be accessed and manipulated through the /httpexchanges actuator endpoint.

You can also create your own implementation of the HttpExchangeRepository interface if you want to store the recorded HTTP exchanges in a different location, such as a database or a file system.

Step 4. Access Actuator HttpExchanges Endpoint

At this moment, the /actuator/httpexchanges endpoint should be enabled. So your next step will be to Build and Run your Spring Boot application.

Once your application is up and running, open the following URL in the browser window:


Refresh the page, and you should get a similar response in response:

                  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15"
                  "gzip, deflate"
                  "Thu, 29 Dec 2022 22:03:56 GMT"

I hope this tutorial was helpful to you. Check out the Spring Cloud and Spring Boot tutorials pages to learn more.

Happy learning!