2011-11-15 78 views
2

在org.apache.log4j类AsyncAppender公共无效setBufferSize(INT大小)“BufferSize”在log4j appender中代表什么?

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后仍然会继续增长! 是什么原因?

回答

3

当某些东西被记录时,它被添加到内存中的事件缓冲区中。然后将此事件缓冲区中的消息写入磁盘。

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