[ 
https://issues.apache.org/jira/browse/LOG4J2-1946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16182806#comment-16182806
 ] 

Frederic Leitenberger commented on LOG4J2-1946:
-----------------------------------------------

We have the same problem.

Logger Config:
{code:xml}
<RollingFile name="externPersistence"
                fileName   ="${sys:workDir}/log/module_externPersistence.xlog"
                
filePattern="${sys:workDir}/log/module_externPersistence.xlog.%i"
                append="true">
        <Policies>
                <SizeBasedTriggeringPolicy size="500MB"/>
        </Policies>
        <DefaultRolloverStrategy max="10"/>
        <PatternLayout pattern="${sys:LOG4J_PATTERN_1}" 
charset="${sys:LOG4J_DEFAULT_CHARSET}" />
</RollingFile>
{code}

Log-File Rotation-Pattern:
{code}
-rw-r--r-- 1 chat chat  46664746 Sep 24 02:40 module_externPersistence.xlog     
# CURRENTLY WRITING
-rw-r--r-- 1 chat chat 524288494 Sep  4 09:21 module_externPersistence.xlog.10 
# ROTATED!
-rw-r--r-- 1 chat chat 524288447 Oct 20  2016 module_externPersistence.xlog.11 
# OLD
-rw-r--r-- 1 chat chat 524288086 Oct 20  2016 module_externPersistence.xlog.12 
# OLD
-rw-r--r-- 1 chat chat 524288600 Oct 20  2016 module_externPersistence.xlog.13 
# OLD
-rw-r--r-- 1 chat chat 524288052 Oct 20  2016 module_externPersistence.xlog.14 
# OLD
-rw-r--r-- 1 chat chat 524289830 Oct 19  2016 module_externPersistence.xlog.15 
# OLD
-rw-r--r-- 1 chat chat 524288168 Oct 19  2016 module_externPersistence.xlog.16 
# OLD
-rw-r--r-- 1 chat chat 524288720 Oct 19  2016 module_externPersistence.xlog.17 
# OLD
-rw-r--r-- 1 chat chat 524288376 Oct 18  2016 module_externPersistence.xlog.18 
# OLD
{code}

For some reason the files 1-9 are missing and only file 10 is rotated.

I assume we had a higher setting for max before and reduced it; the logger then 
deleted file 1-9 and ended up in this buggy state.

> DefaultRolloverStrategy is failing if some log file is deleted from the 
> current sequence
> ----------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1946
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1946
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.8.2
>            Reporter: Lucio Farinosi
>         Attachments: Fixed_ascendingPurge.java, log4j_issue.zip, 
> log4j_trace.log, screenshot-1.png
>
>
> A wrong behaviour in rollover strategy has been reported to me today which is 
> related to a problem on the DefaultRolloverStrategy.
> The case specific settings are:
> - RollingRandomAccessFile appender
> - SizeBasedTriggeringPolicy set to 1MB
> - DefaultRolloverStrategy with max set to 20
> - filePattern without date (i.e. C:/log/test.log.%i)
> When the rollover action begins (the moment the 20th file is completed) if 
> someone deletes one of more files from the current sequence (for example 
> test.log.8 and/or test.log.9 or whatever) the purgeAscending method is 
> failing in engaging the rollover actions in the correct way and this results 
> in a rollover effect limited only to 2 files (the other files are not updated 
> anymore - in a similar way already observed and fixed in 
> https://issues.apache.org/jira/browse/LOG4J2-1821).
> I managed to reproduce the problem in the attached simple project, even in 
> single threaded execution.
> Note that I managed to workaround the problem adding a fake fileIndex to the 
> appender appender.R.strategy.fileIndex=xxxx which results in engaging the 
> purgeDescending method of the same class which is working fine.
> The completed log4j2.properties file is listed below. 
> status=INFO
> monitorInterval=5
> appender.R.type=RollingRandomAccessFile
> appender.R.name=R
> appender.R.fileName=C:/log/test.log
> appender.R.layout.type=PatternLayout
> appender.R.layout.pattern=%d{dd-MM-yyyy HH:mm:ss,SSS} [%mdc] %p %c{1.} [%t] 
> %m %ex%n
> appender.R.filePattern=C:/log/test.log.%i
> appender.R.policies.type=Policies
> appender.R.policies.size.type=SizeBasedTriggeringPolicy
> appender.R.policies.size.size=1MB
> appender.R.strategy.type=DefaultRolloverStrategy
> appender.R.strategy.max=20
> rootLogger.level=INFO
> rootLogger.appenderRef.R.ref=R
> #added to workaround the issue
> #appender.R.strategy.fileIndex=xxxx
> Could you please check it out and/or advise accordingly?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to