DZone

In this article, I will try to explain an approach for logging Spring-based Rest APIs. Although Spring provides tracing of request and responses using its Actuator, logging the request and response body is not supported out of the box. This sometimes makes it difficult to find what is coming to and going from the Rest APIs.

There are several approaches for writing a logger for Spring applications. One of them is writing a listener. But when you write a listener, it starts to work for all the APIs. In this demonstration, we will focus on logging only the APIs that we annotate with our own logging annotation. 

Source: DZone