JUL to SLF4J Bridge

前端 未结 5 1400
小蘑菇
小蘑菇 2020-11-27 11:57

I\'m currently observing that a 3rd party library (namely restfb) is using java.util.logging and I\'m seeing those logs end up in STDOUT even though I don\'t have an SLF4J c

5条回答
  •  眼角桃花
    2020-11-27 12:23

    As mentioned in the javadocs for SLF4JBridgeHandler, you get either install SLF4JBridgeHandler programmatically by invoking:

     // Optionally remove existing handlers attached to j.u.l root logger
     SLF4JBridgeHandler.removeHandlersForRootLogger();  // (since SLF4J 1.6.5)
    
     // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
     // the initialization phase of your application
     SLF4JBridgeHandler.install();
    

    or via logging.properties

     // register SLF4JBridgeHandler as handler for the j.u.l. root logger
     handlers = org.slf4j.bridge.SLF4JBridgeHandler
    

    As for performance, the section on jul-to-slf4j bridge discusses this issue. In essence, since you are already using logback, enabling the LevelChangePropagator should yield good performance regardless of the load.

提交回复
热议问题