简体   繁体   中英

Netty internal logger issue

I am using Netty 4.1.6. Is it possible to set netty using log4j2 as internal logger? Eclipse prompt me that the following statement is depreciated.

InternalLoggerFactory.setDefaultFactory(new Log4J2LoggerFactory());

Would you tell me how to do so?

Thanks Ferrybig for the tip.

I am elaborating on how to do this on log4j2.

Before you do the Netty server bootstrap, insert this line above.

InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(bossGroup, workerGroup)
 .channel(NioServerSocketChannel.class)
 .handler(new LoggingHandler(LogLevel.INFO))
 .childHandler(new ...

Then on the log4j2.xml have the loggers and the corresponding Appenders.

<Logger name="io.netty" level="INFO" additivity="false">
   <AppenderRef ref="nettyTrace"/>
</Logger>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM