You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2019/06/01 17:18:00 UTC

[jira] [Resolved] (LOG4J2-2620) Incorrect rotated file name with RollingFile and TimeBasedTriggeringPolicy

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

Ralph Goers resolved LOG4J2-2620.
---------------------------------
    Resolution: Duplicate

> Incorrect rotated file name with RollingFile and TimeBasedTriggeringPolicy
> --------------------------------------------------------------------------
>
>                 Key: LOG4J2-2620
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2620
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.11.2
>         Environment: Windows 8.1 Pro x64
> JDK 11.0.3
> {code}
> openjdk 11.0.3-BellSoft 2019-04-16
> LibericaJDK Runtime Environment (build 11.0.3-BellSoft+12)
> LibericaJDK 64-Bit Server VM (build 11.0.3-BellSoft+12, mixed mode)
> {code}
>            Reporter: Andrey Turbanov
>            Priority: Major
>         Attachments: log4j2_strange_filenames.png, post-loader-log4j2.xml
>
>
> I use RollingFile appender with 2 policies: TimeBasedTriggeringPolicy and SizeBasedTriggeringPolicy to rotate big files and rotate file at the new day (full configuration attached as well)
> {code}
>         <RollingFile name="RollingFile">
>             <FileName>log/${sys:appName}.log</FileName>
>             <FilePattern>log/${sys:appName}.%d{yyyy-MM-dd}.%i.log.zip</FilePattern>
>             <PatternLayout>
>                 <Pattern>%d{MM-dd HH:mm:ss} %-5p[%t] %c{1} - %m%n</Pattern>
>             </PatternLayout>
>             <Policies>
>                 <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
>                 <SizeBasedTriggeringPolicy size="10 MB"/>
>             </Policies>
>             <DefaultRolloverStrategy max="10"/>
>         </RollingFile>
> {code}
> I run my application every day at ~ {{15:20}}. It runs for 2 hours and then close. Java system property {{appName}} passed to java command line like this: {{-DappName=posts-load}}.
> Usually my application generates ~ 15 MB logs per day.
> So after every run log4j2 leaves 2 files with "todays" log.
> E.g. from 2019-05-31:
> # {{posts-load.log}} 
> # {{posts-load.2019-05-31.1.log.zip}}.
> I expect that when I run application next day my application will leave 4 files with following names:
> # {{posts-load.log}}
> # {{posts-load.2019-06-01.1.log.zip}}
> # {{posts-load.2019-05-31.2.log.zip}} - rotated {{posts-load.log}} from previous day
> # {{posts-load.2019-05-31.1.log.zip}}
> But log4j2 uses some strange file name for rotated {{posts-load.log}}  from previous day, not what I expect:
> # {{posts-load.log}}
> # {{posts-load.2019-06-01.1.log.zip}}
> # {{posts-load.2019-05-09.10.log.zip}}
> # {{posts-load.2019-05-31.1.log.zip}}
> I don't understand why it selected {{2019-05-09}} as rotating day? Is it some problem with my configuration or it's a bug in log4j2?
> As you can see it repeated every day. E.g. {{posts-load.2019-05-09.10.log.zip}} contains logs from 2019-05-31, {{posts-load.2019-05-09.09.log.zip}} contains logs from 2019-05-30, etc.
>  !log4j2_strange_filenames.png! 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)