How to configure netty logger factory in order to see the output of LoggingHandler?

前端 未结 1 1950
醉梦人生
醉梦人生 2021-02-19 07:57

I am using slf4j logging with logback and at the beginning of my app I wrote

InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());

相关标签:
1条回答
  • 2021-02-19 08:11

    I have done a small example, that does work - I placed it on gist on github. It uses logback as the backend of the slf4j. The moments that should be paid attention to are:

    • InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE); should be executed right on the entry point of your program. Sometimes this "entry point" may be very hard to determine.
    • Proper configuration of slf4j backend. Since slf4j is only a wrapper it does not deal with configuration at all - it is specific for log4j, logback or java.util.logging (or maybe some custom backend - I have worked heavily with the custom "java commons logging" configurator, so really anything really can be used)
    • Even without LoggingHandler you should see two debug messages from static initializer of org.jboss.netty.channel.socket.nio.SelectorUtil (with Netty version 3.6.0.Final):

      11:54:00.959 [main] DEBUG o.j.n.c.socket.nio.SelectorUtil - Using select timeout of 500
      11:54:00.962 [main] DEBUG o.j.n.c.socket.nio.SelectorUtil - Epoll-bug workaround enabled = false
      
    0 讨论(0)
提交回复
热议问题