我在tomcat7上安装了一个spring boot web应用程序。我正在寻找一种方法来记录http传入和传出请求(标题和正文)。我正在寻找类似于org.apache.cxf.interceptor.LoggingOutInterceptor的东西。 你能帮忙吗?
答案 0 :(得分:3)
您可以实现自己的过滤器,如:
@Component
public class SimpleFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
// logic...
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {}
public void destroy() {}
}
对于拦截请求和响应的两个要求,这也是一个很好的解决方案......