logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Log4j 2.x - RollingRandomAccessFileAppender missing "createOnDemand" attribute (although documented as valid)

Open JWT007 opened this issue 1 year ago • 1 comments

In the new Log4j 2.x online documentation:

https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html

The configuration attribte 'createOnDemand' is documented as a common attribute for both RollingFileAppender and RollingRandomAccessFileAppender.

Looking at most current code (2.24.1) it seems to only be an attribute of the RollingFileAppender.

NOTE: I originally created a ticket for this on the JIRA to which @ppkarwasz mentioned that this is probably a bug. https://issues.apache.org/jira/browse/LOG4J2-3690

If so, I assume that the attribute needs to be duplicated in RollingRandomAccessFileAppender.

Reading the documentation and looking at the code it almost seems like there is a missing link in the inheritence chain :)

class AbstractRollingFileAppender extends AbstractOutputStreamAppender

JWT007 avatar Oct 14 '24 10:10 JWT007

@JWT007,

Thanks for reporting this.

Although we could solve this with a documentation update, I am classifying this as a feature request. Without discussing the merit of the createOnDemand configuration attribute itself, I find the lack of this feature in many variants of the file and rolling file appenders a bug. Personally I consider all those plugins as variants of either the File Appender or the RollingFile Appender. Generic features like createOnDemand should be introduced to all 5 plugins (or none at all :wink:).

ppkarwasz avatar Oct 14 '24 11:10 ppkarwasz