Description
Unlike the simple FileAppender (both from a Log4j 1.x and 2.x configuration) and the RollingFileAppender configured from a 2.x configuration, the property "immediateFlush" has the value "false" on RollingFileAppender configured from a Log4j 1.x configuration. This leads to apparently not logging into the file (the automatic flush occurs only after a high amount of data and respectively a long time).
The code reveals two relevant differences:
- "immediateFlush" has the fixed default-value "false" in the 1.x configuration-flow (see for eg.
org.apache.log4j.builders.appender.RollingFileAppenderBuilder.parseAppender()
, the same as in
org.apache.log4j.builders.appender.FileAppenderBuilder.parseAppender()
), unlike in the 2.x configuration-flow (
org.apache.log4j.core.appender.AbstractOutputStreamAppender.Builder.immediateFlush
has the default-value "true")
- the value of "immediateFlush" is taken from
!bufferedIo || isImmediateFlush()
for a FileAppender, which is missing from the RollingFileAppender
To reproduce, build and start the attached demo-application (initializes Log4j2 from a Log4j 1.x configuration and prints periodically a log-entry to the console, to a FileAppender and to a RollingFileAppender). Execute "tail -f" on the file of the simple appender (log.log) and on that of the rolling appender (rlog.log) and observe, that logging output doesn't appear on the latter, until the application is stopped.
Attachments
Attachments
Issue Links
- links to