Details
-
Bug
-
Status: Open
-
Trivial
-
Resolution: Unresolved
-
2.9.1
-
None
-
None
-
CentOS & MacOS
JVM 1.8 (reproducible on latest build)
Description
One appender filePattern is set with "log.gz", another appender is set with ".log". In this case what is observed is that the log.gz rollover with no compression, removing the appender with filePattern set with no compression work around this
Here is how log4j2.properties look like
appender.rolling.type = RollingFile appender.rolling.name = plain_rolling appender.rolling.fileName = /path/plainlog.log appender.rolling.filePattern = /path/plainlog-%d{yyyy-MM-dd-HH-mm-ss}.log.gz appender.rolling.policies.type = Policies appender.rolling.policies.time.type = TimeBasedTriggeringPolicy appender.rolling.policies.time.interval = 1 appender.rolling.policies.time.modulate = true appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %-.10000m%n #This section/appender is not even used in the application as a setting is logging in plain appender.json_rolling.type = RollingFile appender.json_rolling.name = json_rolling appender.json_rolling.fileName = /path/jsonlog.log appender.json_rolling.filePattern = /path/jsonlog-%d{yyyy-MM-dd-HH-mm-ss}.log appender.json_rolling.policies.type = Policies appender.json_rolling.policies.time.type = TimeBasedTriggeringPolicy appender.json_rolling.policies.time.interval = 1 appender.json_rolling.policies.time.modulate = true appender.json_rolling.layout.type = JSONLayout appender.json_rolling.layout.compact = true appender.json_rolling.layout.eventEol = true
With above configuration the following files will contain plain text
/path/plainlog-%d{yyyy-MM-dd-HH-mm-ss}.log.gz
Commenting out appender "json_rolling" or setting filePattern to .log.gz cause the plainlog-*.log.gz to be compressed as expected :
appender.json_rolling.filePattern = /path/jsonlog-%d{yyyy-MM-dd-HH-mm-ss}.log
I am expecting this is or was a Bug in log4j code or possibly documentation because I could not see this behaviour is documented clearly