[ https://issues.apache.org/jira/browse/LOG4J2-2457?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Heiko Schwanke reopened LOG4J2-2457: ------------------------------------ The patch creates files with .gz extension after reconfiguration, but they are not compressed. Too bad i missed that at first hand - sorry! In case of an update the fileExtension of the RollingFileManager attribute is not updated. The methods {code:java} org.apache.logging.log4j.core.appender.rolling.RollingFileManager.updateData(Object) and org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.updateData(Object) {code} should also update {code:java} org.apache.logging.log4j.core.appender.rolling.RollingFileManager.fileExtension {code} too. This attribute is taken into account when a rollover occurs. {code:java} org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.rollover(RollingFileManager) {code} Currently it is still {{null}} after reconfiguration from {{xxx.log}} to {{xxx.log.gz}}. > RollingRandomAccessFileManager ignores new file patterns from programmatic > reconfiguration > ------------------------------------------------------------------------------------------ > > Key: LOG4J2-2457 > URL: https://issues.apache.org/jira/browse/LOG4J2-2457 > Project: Log4j 2 > Issue Type: Bug > Components: Appenders, Configurators > Affects Versions: 2.11.1 > Reporter: Heiko Schwanke > Priority: Major > Fix For: 3.0.0, 2.11.2 > > Attachments: testcase.zip > > > I use the Composite Configuration feature with two configuration files and > set the System-Property "log4j.configurationFile" programmatically. > > {code:java} > System.setProperty("log4j.configurationFile", > "log4j2.xml,log4j2-test-rotategz.xml"); > LoggerContext ctx = (LoggerContext) LogManager.getContext(false); > ctx.reconfigure(); > {code} > > The first config file defines an appender > > {noformat} > <RollingRandomAccessFile name="MyRollingFile" fileName="c:/temp/my.log" > filePattern="c:/temp/my.log-%d{yyyy-MM-dd_HH-mm-ss}">{noformat} > > and the second overwrites it with a different file pattern (.gz) > > {noformat} > <RollingRandomAccessFile name="MyRollingFile" fileName="c:/temp/my.log" > filePattern="c:/temp/my.log-%d{yyyy-MM-dd_HH-mm-ss}.gz">{noformat} > > As expected when i run my application the file rotation happens uncompressed > until the programmatic reconfiguration. > But after the programmatic reconfiguration the rotated files are still > uncompressed. > The following code is responsible for this behaviour: > > {code:java} > org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.updateData(Object) > public void updateData(final Object data) { > final FactoryData factoryData = (FactoryData) data; > this.setRolloverStrategy(factoryData.getRolloverStrategy()); > this.setTriggeringPolicy(factoryData.getTriggeringPolicy()); > } > {code} > > Looking at the parent class, i can see that patterns are updated too: > {code:java} > org.apache.logging.log4j.core.appender.rolling.RollingFileManager.updateData(Object) > public void updateData(final Object data) { > final FactoryData factoryData = (FactoryData) data; > setRolloverStrategy(factoryData.getRolloverStrategy()); > setTriggeringPolicy(factoryData.getTriggeringPolicy()); > setPatternProcessor(new PatternProcessor(factoryData.getPattern(), > getPatternProcessor())); > } > {code} > > If i do the same in RollingRandomAccessFileManager everything works as > expected. > Please take note of the attached testcase, which contains all resources > needed to reproduce easily. > I would really appreciate, if you could investigate and fix this issue. > Thank you so much in advance. > Best regards > Heiko -- This message was sent by Atlassian Jira (v8.3.4#803005)