You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2015/10/14 06:49:05 UTC
[jira] [Commented] (LOG4J2-1087) Reload of RolloverStrategy doesn't
work
[ https://issues.apache.org/jira/browse/LOG4J2-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14956256#comment-14956256 ]
Ralph Goers commented on LOG4J2-1087:
-------------------------------------
In order to reconfigure safely Log4j uses "managers" for the appenders. In some cases the managers will span reconfigurations in order not to require significant locking or the loss of events. In the case of the RollingFileAppender the "key" for the manager is the filename only. So when a reconfiguration occurs the manager is not recreated and is reused instead. The parameters on the manager are all final, again to avoid locking and to insure it is thread-safe.
So the only way to change the max parameter is to change the filename, let it reconfigure, then change the filename back and change the max attribute during one of those two updates.
> Reload of RolloverStrategy doesn't work
> ---------------------------------------
>
> Key: LOG4J2-1087
> URL: https://issues.apache.org/jira/browse/LOG4J2-1087
> Project: Log4j 2
> Issue Type: Bug
> Reporter: Benjamin Jaton
> Attachments: reload.txt
>
>
> I am using this configuration :
> {code}<?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="DEBUG" monitorInterval="2">
> <Appenders>
> <RollingFile name="RollingFile" fileName="/tmp/test/app.log" filePattern="/tmp/test/app.log.%i">
> <PatternLayout>
> <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
> </PatternLayout>
> <Policies>
> <SizeBasedTriggeringPolicy size="100KB"/>
> </Policies>
> <DefaultRolloverStrategy max="5"/>
> </RollingFile>
> </Appenders>
> <Loggers>
> <Root level="info" includeLocation="false">
> <AppenderRef ref="RollingFile"/>
> </Root>
> </Loggers>
> </Configuration>{code}
> I am changing the DefaultRolloverStrategy "max" attribute from 5 to 10.
> I can see the reloading take place from the StatusLogger (full log attached):
> {code}DEBUG Starting configuration XmlConfiguration[location=/usr/local/apps/log4j2-test.xml]
> (...)
> DEBUG Found factory method [createStrategy]: public static org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.createStrategy(java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.apache.logging.log4j.core.config.Configuration).
> 2015-07-24 12:08:00,938 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(name="10", name="null", name="null", name="null", Configuration(/usr/local/apps/log4j2-test.xml)){code}
> So log4j2 is seeing the changes, but there is still only 5 files produced 1->5.
> (I made sure that I was producing enough log data)
> If I change the message pattern, I see it change in the log file, but not the RolloverStrategy parameters.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org