[
https://issues.apache.org/jira/browse/LOG4J2-2457?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Heiko Schwanke closed LOG4J2-2457.
----------------------------------
Works now as expected - great work Ralph, thank you a lot.
> 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, 2.13.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)