How do you flush a buffered log4j FileAppender?

前端 未结 7 1757
感动是毒
感动是毒 2020-12-01 09:49

In log4j, when using a FileAppender with BufferedIO=true and BufferSize=xxx properties (i.e. buffering is enabled), I want to be able to flush the log during normal shutdown

7条回答
  •  囚心锁ツ
    2020-12-01 10:17

    I have written an appender that fixes this, see GitHub or use name.wramner.log4j:FlushAppender in Maven. It can be configured to flush on events with high severity and it can make the appenders unbuffered when it receives a specific message, for example "Shutting down". Check the unit tests for configuration examples. It is free, of course.

提交回复
热议问题