You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Heiko Schwanke (JIRA)" <ji...@apache.org> on 2018/09/27 11:43:00 UTC

[jira] [Updated] (LOG4J2-2457) RollingRandomAccessFileManager ignores new file patterns from programmatic reconfiguration

     [ https://issues.apache.org/jira/browse/LOG4J2-2457?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heiko Schwanke updated LOG4J2-2457:
-----------------------------------
    Summary: RollingRandomAccessFileManager ignores new file patterns from programmatic reconfiguration  (was: Programmatic reconfiguration of RollingRandomAccessFileManager ignores new file patterns)

> 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
>         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
(v7.6.3#76005)