2

I have a Spring Boot backend application and I'd like to list all the REST API calls made by clients to my application. I'm running my app in Tomcat/nginx.

1 Answers1

0

Way 1 (Actuator): You can track last 100 request using Spring Boot Actuator. Here is the way to do this :

Add the maven dependency:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

Edit the application.properties and add the following line:

management.endpoints.web.exposure.include=* 

After running your spring boot application, now you can track the latest 100 http requests by calling this url: http://localhost:8070/actuator/httptrace

Way 2 (Aspect):

But you can also get the log using Aspect.

It provide you some amazing annotation like: @Before , @AfterReturning, @AfterThrowing etc.

Here @Before log the url,request parameters, @AfterReturning log the response parameters and @AfterThrowing log the error with message, You may not don't need all endpoints log, so here have some filters based on package.

To implement this feature using aspects check this anawer

Md. Sajedul Karim
  • 6,749
  • 3
  • 61
  • 87