Tag: interceptor
-
How to log incoming requests to all REST services in Spring Boot?
(As an alternate to the below solution you can check out this post , which is easier and more straightforward) Let’s say you want to log all the requests to your REST APIs developed using Spring Boot in a centralized way. You don’t want to add logs to each and every API. How to do…
-
How to log IP addresses of incoming requests to a Spring Boot app in a centralized way?
Let’s say you want to track the source of hits coming to your REST services. And you have developed them using Spring Boot. Here is the algorithm: STEP1: Create a Spring Handler Interceptor STEP2: Retrieve the IP address in the prehandle method of the Handler interceptor. 2.a) Use X-Forwarded-For header extracted from HttpRequest object to…