有没有办法在 netty 输出中打开纯文本日志记录?
如何在 netty 中打开纯文本日志记录?
谢谢
最佳答案
将 LoggingHandler
添加到您的管道:
pipeline.addLast("logger", new LoggingHandler());
默认情况下,此处理程序记录到控制台,但您可以定义不同的LoggererFactory
。
来自 JavaDoc:
Creates an InternalLogger or changes the default factory implementation. This factory allows you to choose what logging framework Netty should use. The default factory is Slf4JLoggerFactory. If SLF4J is not available, Log4JLoggerFactory is used. If Log4J is not available, JdkLoggerFactory is used. You can change it to your preferred logging framework before other Netty classes are loaded: InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
Please note that the new default factory is effective only for the classes which were loaded after the default factory is changed. Therefore, setDefaultFactory(InternalLoggerFactory) should be called as early as possible and shouldn't be called more than once.
关于java - 如何在 netty 中打开纯文本日志记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30379007/