How to create a Spring Interceptor for Spring RESTful web services

Following steps can be taken to implement the interceptor with Spring: Implement an interceptor class extending HandlerInterceptorAdapter class. Following is how the code could look like: public class LoginInterceptor extends HandlerInterceptorAdapter { @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) throws Exception { // TODO Auto-generated method stub } @Override public void … Read more

Spring Boot – How to log all requests and responses with exceptions in single place?

Don’t write any Interceptors, Filters, Components, Aspects, etc., this is a very common problem and has been solved many times over. Spring Boot has a modules called Actuator, which provides HTTP request logging out of the box. There’s an endpoint mapped to /trace (SB1.x) or /actuator/httptrace (SB2.0+) which will show you last 100 HTTP requests. … Read more