如何使用jersey启用spring boot 1.2.5来打印原始http请求和响应控制台?

时间:2015-12-09 02:39:10

标签: http logging spring-boot jersey-2.0

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

1 个答案:

答案 0 :(得分:2)

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));
    }
}