I've been trying to find a way to log the response body of requests in my spring boot application. I've abandoned this for now and will just log in each controller before returning, because the effort to get this to work (globally, for all controllers with a Filter or request interceptor) seems inordinately large / overly complicated.
In python django projects, it seems this could be as simple as a middleware with something like log.info(response.body)
.
I'm new to Java, so I am sure there is a valid reason, but can someone explain WHY?
To try to get a string representation of the response body in java, from an HttpServletResponse involves all sorts of wrangling like this