LoggingFeature无效

时间:2017-02-01 01:26:13

标签: rest jersey-2.0 jersey-client

我正在使用2.25.1版本的jersey rest api(JAX-RS)。我试图在服务器端和客户端使用LoggingFeature类。

客户端代码:

public static void getOperation() {

            ClientConfig config = new ClientConfig();
            config.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_CLIENT, LoggingFeature.Verbosity.PAYLOAD_ANY);
            config.register(new LoggingFeature(logger, LoggingFeature.Verbosity.PAYLOAD_ANY));
            Client client = ClientBuilder.newClient(config);
            client.register(ClientEmpReqFilter.class);
            client.register(ClientEmpResFilter.class);

            WebTarget target = client.target("http://localhost:8080").path("restappln/rest/entity");

            String str = target.request(MediaType.APPLICATION_JSON).get(String.class);

            System.out.println(str);
        }

和服务器端代码是:

@ApplicationPath("/rest")
public class MyApplication extends ResourceConfig {
    public MyApplication() {
        packages("<package name>");
        register(LoggingFeature.class);
    }
}

我无法登录。我将java.util.Logger的实例传递给客户端配置的构造函数。

config.register(new LoggingFeature(logger, LoggingFeature.Verbosity.PAYLOAD_ANY));

0 个答案:

没有答案