apache / logging-log4j2

Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
https://logging.apache.org/log4j/2.x/
Apache License 2.0
3.4k stars 1.62k forks source link

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

Open JWT007 opened 1 month ago

JWT007 commented 1 month ago

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

ppkarwasz commented 1 month ago

@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:).