How to make Jersey to use SLF4J instead of JUL?

后端 未结 6 734
野的像风
野的像风 2020-12-25 12:22

I\'ve found a useful article that explains how to make Jersey to use SLF4J instead of JUL. Now my unit test looks like (and it works perfectly):

public class         


        
6条回答
  •  长发绾君心
    2020-12-25 12:48

    If you are using the client API you can manually redirect the logs to slf4j (note that it may break in future versions although it seems unlikely):

    Logger LOG = LoggerFactory.getLogger(MyClass.class); //slf4j logger
    
    WebTarget ws = ClientBuilder.newClient(config)
                      .register(new LoggingFilter(new JulFacade(), true));
    
    private static class JulFacade extends java.util.logging.Logger {
      JulFacade() { super("Jersey", null); }
      @Override public void info(String msg) { LOG.info(msg); }
    }
    

提交回复
热议问题