简体   繁体   English

Project Reactor使用slf4j进行非阻塞日志记录

[英]Project Reactor non-blocking logging with slf4j

The log() method in Flux.class for Project Reactor mentions that if slf4j is available, it will be used. Project Reactor的Flux.classlog()方法提到如果slf4j可用,它将被使用。 If you use a logger implementation like logback with slf4j, they are by default blocking, especially the write to file/disk part. 如果您使用loglf实现,例如使用slf4j进行logback ,则默认情况下会阻塞它们,尤其是写入文件/磁盘部分。 The Reactor documents don't mention anything about this. Reactor文件没有提及任何相关信息。 Does anyone have thoughts/experience on this? 有没有人有这方面的想法/经验? I think one option is to maybe setup logback as async. 我认为一种选择是将logback设置为异步。 Are there any other options? 还有其他选择吗? Thanks! 谢谢!

I am not sure if that is an answer to your question, but by using reactor-logback I assumed that I am logging asynchronously. 我不确定这是否是您的问题的答案,但通过使用reactor-logback我假设我异步记录。

I added the following log configuration (logback-spring.xml example) 我添加了以下日志配置(logback-spring.xml示例)

<!-- Wrap calls to the logger. -->
<appender name="asyncFile" class="reactor.logback.AsyncAppender">
  <appender-ref ref="FILE"/>
</appender>

I found this information here . 我在这里找到了这个信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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