Reputation: 6189
I want to intercept Spring servlet response just at the end of the request. I mean, what i want to do is to log service response, that json which services returns and the statusCode. That is all what i want to log.
For that, i've already tried using HandlerInterceptorAdapter like this
public class ResponseLoggerInterceptor
extends HandlerInterceptorAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(ResponseLoggerInterceptor.class);
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
LOGGER.info("Intercepted");
super.postHandle(request, response, handler, modelAndView);
}
}
That "handler" object is the object respose, but it is not serialized. Do you know where and how i have to intercept the very last servlet response? Thanks in advance
Upvotes: 0
Views: 2137
Reputation: 3073
You will need a 'HttpResponse' object And will suggest that you do it in the 'afterCompletion' method
Upvotes: 1