3

在 org.apache.log4j 类 AsyncAppender public void setBufferSize(int size)

Sets the number of messages allowed in the event 
 buffer before the calling thread is blocked (if blocking is true) 
or until messages are summarized and discarded. Changing the size 
will not affect messages already in the buffer. 

我已经配置了 10,000 个。但是文件还在10K之后继续增长!是什么原因?

4

1 回答 1

3

记录某些内容时,会将其添加到内存中的事件缓冲区中。然后将此事件缓冲区中的消息写入磁盘。

如果您记录事物的速度快于它们写入磁盘的速度,则事件缓冲区会填满。在您的情况下,如果事件缓冲区达到 10,000 条消息,则日志记录机制会采取措施将其保持在 10,000 条或更低:要么阻塞直到缓冲区写入磁盘,要么丢弃日志消息。

于 2011-11-15T13:25:14.043 回答