Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.11.1
-
None
Description
I use the Composite Configuration feature with two configuration files and set the System-Property "log4j.configurationFile" programmatically.
System.setProperty("log4j.configurationFile", "log4j2.xml,log4j2-test-rotategz.xml"); LoggerContext ctx = (LoggerContext) LogManager.getContext(false); ctx.reconfigure();
The first config file defines an appender
<RollingRandomAccessFile name="MyRollingFile" fileName="c:/temp/my.log" filePattern="c:/temp/my.log-%d{yyyy-MM-dd_HH-mm-ss}">
and the second overwrites it with a different file pattern (.gz)
<RollingRandomAccessFile name="MyRollingFile" fileName="c:/temp/my.log" filePattern="c:/temp/my.log-%d{yyyy-MM-dd_HH-mm-ss}.gz">
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:
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()); }
Looking at the parent class, i can see that patterns are updated too:
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())); }
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
Attachments
Attachments
Issue Links
- is related to
-
LOG4J2-2766 TimeBasedTriggeringPolicy of RollingRandomAccessFile is not updated instantly
- Closed