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

ASF subversion and git services commented on LOG4J2-2784:
---------------------------------------------------------

Commit af0ed7f4869876a08b6c8f37c06a1ca477345cd8 in logging-log4j2's branch 
refs/heads/release-2.x from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=af0ed7f ]

LOG4J2-2784 - Counter stuck at 10 and overwriting files when leading zeros used 
in the file pattern count.


> Rolling stuck at counter 10 by RollingFile appender when counter is zero 
> padded
> -------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2784
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2784
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.12.1, 2.13.0
>         Environment: Windows 10 Pro x64 v1809
> Oracle Java 11.0.3
>            Reporter: Petras
>            Assignee: Ralph Goers
>            Priority: Major
>
> We are using rolling file appender with SizeBasedTriggeringPolicy. The 
> counter in file name is padded with 0. We observed that Log4j2 RollingFile 
> appender does not increment the counter beyond 10 and overwrites the 10th 
> rolled file.
> Simple test case:
> {code:java}
> import org.apache.commons.lang3.RandomStringUtils;
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> public class LogTest {
>     private static final Logger logger = LogManager.getLogger("LogTest");
>     public static void main(String[] args) throws Exception
>     {
>         for (long i=0; ; i+=1) {
>             logger.info("Sequence: " + i);
>             logger.debug(RandomStringUtils.randomAscii(128, 512));
>             Thread.sleep(250);
>         }
>     }
> }
> {code}
> The log4j2.xml configuration:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="debug" verbose="true" dest="err" name="XmlProperties">
>     <Properties>
>         <Property name="baseFilename">rolling_test.log</Property>
>         <Property name="pattern">%d{HH:mm:ss.SSS} [%t] %-5level %logger{1.} - 
> %msg%n</Property>
>     </Properties>
>     <Appenders>
>         <Console name="Console" target="SYSTEM_OUT">
>             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level 
> %logger{36} - %msg%n"/>
>         </Console>
>         <RollingFile name="RollingFile" fileName="${baseFilename}" 
> filePattern="${baseFilename}.%02i" immediateFlush="true" append="true">
>             <PatternLayout pattern="${pattern}"/>
>             <Policies>
>                 <SizeBasedTriggeringPolicy size="1 KB"/>
>             </Policies>
>             <DefaultRolloverStrategy max="99"/>
>         </RollingFile>
>     </Appenders>
>     <Loggers>
>         <Logger name="LogTest" level="trace"/>
>         <Logger name="org.apache.logging.log4j.status" level="trace"/>
>         <Root level="info">
>             <AppenderRef ref="Console" level="info"/>
>             <AppenderRef ref="RollingFile"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> Log4j2 creates the files:
> {code}
> rolling_test.log
> rolling_test.log.01
> rolling_test.log.02
> rolling_test.log.03
> rolling_test.log.04
> rolling_test.log.05
> rolling_test.log.06
> rolling_test.log.07
> rolling_test.log.08
> rolling_test.log.09
> rolling_test.log.10
> {code}
> When counter 10 is reached, {{rolling_test.log.10}} file is being overwritten 
> when rolled.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to