Netty内部记录器问题 [英] Netty internal logger issue

查看:147
本文介绍了Netty内部记录器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netty 4.1.6. 是否可以使用log4j2作为内部记录器来设置netty? Eclipse提示我以下语句已贬值.

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());

你能告诉我怎么做吗?

推荐答案

感谢Ferrybig的提示.

Thanks Ferrybig for the tip.

我正在详细说明如何在log4j2上执行此操作.

I am elaborating on how to do this on log4j2.

在执行Netty服务器引导之前,请在上方插入此行.

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 ...

然后在log4j2.xml上具有记录器和相应的Appender.

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

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

这篇关于Netty内部记录器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆