当前位置:   article > 正文

前后端联调拦截器日志打印配置

前后端联调拦截器日志打印配置

打印信息格式:

前端信息

后端信息

springboot下配置

  1. import net.sf.json.JSONObject;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;
  4. import org.springframework.context.annotation.Configuration;
  5. import javax.servlet.*;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import java.io.IOException;
  9. import java.util.*;
  10. @Configuration
  11. public class LoggingFilterConfig implements Filter {
  12. private static final Logger logger = LoggerFactory.getLogger(LoggingFilterConfig.class);
  13. @Override
  14. public void init(FilterConfig filterConfig) throws ServletException {
  15. }
  16. @Override
  17. public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  18. HttpServletRequest req = (HttpServletRequest) request;
  19. HttpServletResponse res = (HttpServletResponse) response;
  20. Map<String, Object> map = new HashMap<String, Object>();
  21. HttpServletRequest requestWrapper = null;
  22. // LogPosition使用时间戳作为日志的定位数字,在idea的控制台中使用Ctrl+f调出查询框,
  23. // 让前端将异常接口的Lo
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/550852
推荐阅读
相关标签
  

闽ICP备14008679号