Rest 日志功能不工作

Rest 日志功能不工作,rest,jersey-2.0,jersey-client,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, Logging

我正在使用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);
    }
}

您能否从config.register(新的LoggingFeature(logger…?和异常的堆栈跟踪)中显示记录器的代码;它是java的util包中的简单记录器。您应该删除导致编译错误的行。如果要注册(),请与Jersey文档中一样你的配置类应该是ResourceConfig而不是ClientConfig类型。更多信息:我已经发布了一个类似问题的解决方案,链接:你能从config.register(新的LoggingFeature(logger…?和异常的堆栈跟踪)显示logger的代码吗?logger=logger.getLogger();它是java的util包中的简单记录器。您应该删除导致编译错误的行。与Jersey文档中一样,如果您想注册(),您的配置类应该是ResourceConfig而不是ClientConfig类型。更多信息:我已经发布了一个类似问题的解决方案,链接:
config.register(new LoggingFeature(logger, LoggingFeature.Verbosity.PAYLOAD_ANY));