【问题标题】:How can I enable spring boot 1.2.5, using jersey, to print the raw http request and response to the console?如何使用 jersey 启用 spring boot 1.2.5 以将原始 http 请求和响应打印到控制台?
【发布时间】:2015-12-09 02:39:10
【问题描述】:

我有一个使用 jersey 2 的 spring boot 1.2.5 服务。我在自己的日志中看到了请求,但我也想在控制台中看到原始的 http 请求和响应。如何开启将 http 流量打印到控制台?

【问题讨论】:

    标签: http logging spring-boot jersey-2.0


    【解决方案1】:
    import java.util.logging.Logger;
    import org.glassfish.jersey.filter.LoggingFilter;
    import javax.ws.rs.ApplicationPath;
    import org.springframework.stereotype.Component;
    
    @Component
    @ApplicationPath("/")
    public class JerseyConfiguration extends ResourceConfig {
        private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
    
        public JerseyConfiguration() {
            ...
    
            register(new LoggingFilter(log, true));
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-20
      • 1970-01-01
      • 2013-03-19
      • 2018-07-28
      • 2015-04-21
      • 2014-01-06
      • 1970-01-01
      • 2012-06-10
      • 2019-07-14
      相关资源
      最近更新 更多