How to make Jersey to use SLF4J instead of JUL?

后端 未结 6 739
野的像风
野的像风 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:53

    In my app Jersey logging (with proper pom.xml and logback.xml) works fine only with

        SLF4JBridgeHandler.install(); 
    

    For tests you can make base abstract test with common configuration and extends other JUnit from it:

    public abstract class AbstractTest {
    
        private static final Logger LOG = LoggerFactory.getLogger(AbstractTest.class);
    
        static {
            SLF4JBridgeHandler.install();
        }
    
        @Rule
        public ExpectedException thrown = ExpectedException.none();
    
        @Rule
        // http://stackoverflow.com/questions/14892125/what-is-the-best-practice-to-determine-the-execution-time-of-the-bussiness-relev
        public Stopwatch stopwatch = new Stopwatch() {
            @Override
            protected void finished(long nanos, Description description) {
               ...
    

提交回复
热议问题