Discussion:
[jira] [Created] (LOG4J2-381) Changes in SizeBasedTriggeringPolicy has no effects when automatic reconfiguration is on.
Alexander Khokhlov (JIRA)
2013-09-02 21:25:51 UTC
Permalink
Alexander Khokhlov created LOG4J2-381:
-----------------------------------------

Summary: Changes in SizeBasedTriggeringPolicy has no effects when automatic reconfiguration is on.
Key: LOG4J2-381
URL: https://issues.apache.org/jira/browse/LOG4J2-381
Project: Log4j 2
Issue Type: Bug
Components: Appenders
Affects Versions: 2.0-beta8, 2.0-beta9
Reporter: Alexander Khokhlov


My config is very simple:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Ralph Goers (JIRA)
2013-09-02 23:05:51 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13756259#comment-13756259 ]

Ralph Goers commented on LOG4J2-381:
------------------------------------

This is true because the RollingFileManager is trying to avoid having multiple streams open for the same file (see the Javadoc for java.io.FileOutputStream) so it only uses the file name as the manager's key. The existing RollingFileManager can't be updated as it is designed to be immutable.

Note that this same situation will occur if you configure two RollingFileAppenders int the same configuration that point to the same file or if two web applications are running in Tomcat and share a configuration. You will end up with a single RollingFileManager that is shared by all appender instances.

At the moment, the only way to reconfigure the manager would be to remove the appender (or change its file name), reconfigure, and then add it back with the new definition.
Post by Alexander Khokhlov (JIRA)
Changes in SizeBasedTriggeringPolicy has no effects when automatic reconfiguration is on.
-----------------------------------------------------------------------------------------
Key: LOG4J2-381
URL: https://issues.apache.org/jira/browse/LOG4J2-381
Project: Log4j 2
Issue Type: Bug
Components: Appenders
Affects Versions: 2.0-beta8, 2.0-beta9
Reporter: Alexander Khokhlov
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Anthony Baldocchi (JIRA)
2014-09-24 21:57:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anthony Baldocchi updated LOG4J2-381:
-------------------------------------
Attachment: LOG4J2-381.patch

Attached patch resolves the issue for me.
Post by Alexander Khokhlov (JIRA)
Changes in SizeBasedTriggeringPolicy has no effects when automatic reconfiguration is on.
-----------------------------------------------------------------------------------------
Key: LOG4J2-381
URL: https://issues.apache.org/jira/browse/LOG4J2-381
Project: Log4j 2
Issue Type: Bug
Components: Appenders
Affects Versions: 2.0-beta8, 2.0-beta9
Reporter: Alexander Khokhlov
Attachments: LOG4J2-381.patch
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Remko Popma (JIRA)
2014-09-25 00:18:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma updated LOG4J2-381:
-------------------------------
Description:
My config is very simple:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
{code}
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.


was:
My config is very simple:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.
Post by Alexander Khokhlov (JIRA)
Changes in SizeBasedTriggeringPolicy has no effects when automatic reconfiguration is on.
-----------------------------------------------------------------------------------------
Key: LOG4J2-381
URL: https://issues.apache.org/jira/browse/LOG4J2-381
Project: Log4j 2
Issue Type: Bug
Components: Appenders
Affects Versions: 2.0-beta8, 2.0-beta9
Reporter: Alexander Khokhlov
Attachments: LOG4J2-381.patch
{code}
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' strict="true" monitorInterval="5">
<appenders>
<appender type="console" name="CONSOLE">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m%n"/>
</appender>
<appender name="BOOT" type="rollingfile" fileName="boot.log" filePattern="boot-%i.log" append="true">
<layout type="PatternLayout" pattern="%5p %10c %C{1}(%L) - %m %ex%n"/>
<SizeBasedTriggeringPolicy size="1 kb" />
<DefaultRolloverStrategy />
</appender>
</appenders>
<loggers>
<root level="all">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="BOOT"/>
</root>
</loggers>
</configuration>
{code}
This is because when you create a RollingFileAppender again it uses the previously created RollingFileManager obtained from MAP (AbstractManager (69)). But in my case, the name is already exists, so appropriate manager already been created. But "data" parameter are not the same when manager was created at first time. It contains new value of policy.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...