我对将异步记录器与log4j2一起使用时的默认缓冲区大小有疑问。 log4j2的版本为2.11.2
,由Spring Boot log4j2启动器2.1.13.RELEASE引入。
看来文档中的不同位置引用了不同的值。async logger document将尺寸称为256 * 1024
。但是,log4j2 general config document提到在无垃圾模式下运行时,大小为4 * 1024
,否则为256 * 1024
。默认情况下,在garbage-free mode中运行log4j2及更高版本。
但是,当我将StatusLogger设置为TRACE来启动应用程序时,缓冲区大小显示为262144(256 * 1024)。
DEBUG StatusLogger Creating custom DiscardingAsyncQueueFullPolicy(discardThreshold:INFO)
DEBUG StatusLogger [AsyncContext@685f4c2e] Starting AsyncLogger disruptor for this context with ringbufferSize=262144, waitStrategy=TimeoutBlockingWaitStrategy, exceptionHandler=org.apache.logging.log4j.core.async.AsyncLoggerDefaultExceptionHandler@7a4f0f29...
我会以为大小为4096。是否有人看到过这种行为,或者我在这里错过了什么?
谢谢。-Anoop
[当Log4j在Web应用程序中运行(javax.servlet.Servlet在类路径上)或log4j2.enableThreadLocals系统属性为false时,缓冲区大小将为4 *1024。否则为256 * 1024。