SLF4JBridgeHandler和JUL:如何完全删除JUL显示?

时间:2017-06-22 16:30:25

标签: java slf4j jersey-2.0 java.util.logging

我正在尝试使用Annotation而不是XML来配置Jersey,而这样做我必须将LoggingFilter更改为LoggingFeature。

我设法找到如何对后者进行相同操作,但我真的找不到任何方法来删除JUL日志记录并且只能使用SLF4j / Logback。

这是我的配置:

@ApplicationPath("rest")
public class JerseyConfiguration extends ResourceConfig {

    public JerseyConfiguration() {
        packages("foo.bar.rest");
        register(MultiPartFeature.class);
        register(JacksonFeature.class);
        register(
            new LoggingFeature(
                java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
                java.util.logging.Level.INFO,
                LoggingFeature.Verbosity.HEADERS_ONLY,
                LoggingFeature.DEFAULT_MAX_ENTITY_SIZE)
        );

        // Initialize SLF4J Bridge here (but works globally) as Jersey logs to JUL
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();
    }
}

这是我的日志,第一行(粗体)是slf4j / logback,秒是JUL,所以重定向没问题,但为什么JUL还在记录?有没有办法禁用它? (或者我是否必须将JUL重定向为null或其他什么?)

  

2017-06-22 18:28:36.860 INFO o.g.jersey.logging.LoggingFeature - 4 *服务器响应线程http-nio-8080-exec-5 4< 401 4< 4内容类型:application / json

     

2017年6月22日下午6:28:36   org.glassfish.jersey.logging.LoggingInterceptor log INFO:4 * Server   回应了线程http-nio-8080-exec-5 4< 401 4< 4   Content-Type:application / json

0 个答案:

没有答案
相关问题