You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Aivaras Dziaugys (Jira)" <ji...@apache.org> on 2021/06/01 04:31:00 UTC

[jira] [Commented] (LOG4J2-3101) SizeBasedTriggeringPolicy does not update date on rollover

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

Aivaras Dziaugys commented on LOG4J2-3101:
------------------------------------------

[~rgoers] If it is intended behavior, then documentation should be updated to reflect that. Currently documentation notes that ??When used without a time based triggering policy the SizeBased Triggering Policy will cause the timestamp value to change.??
Found in [https://logging.apache.org/log4j/2.x/manual/appenders.html] 

And using $${date:yyyy-MM-dd} in filePattern does not update date on rollover as well, all log file names were with application start date instead of rollover date.

> SizeBasedTriggeringPolicy does not update date on rollover
> ----------------------------------------------------------
>
>                 Key: LOG4J2-3101
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3101
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.14.1
>         Environment: OS: Windows 10
> SpringBoot: 2.4.4/2.5.0
> Java: Zulu-11
>            Reporter: Aivaras Dziaugys
>            Priority: Minor
>
> Using _RollingFile_ appender with _SizeBasedTriggeringPolicy_ does not update date specified in _filePattern_ on rollover. The dates on log files are always evaluated to start time of the application.
> To quickly reproduce issue I was injecting custom org.apache.logging.log4j.core.util.Clock implementation via LOG4J_CLOCK environment variable.
> My log4j2.xml :
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN" monitorInterval="30">
>     <Properties>
>         <Property name="LOG_PATTERN">%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %p %m%n</Property>
>         <Property name="APP_LOG_ROOT">/home/aivaras/tmp</Property>
>     </Properties>
>     <Appenders>
>         <RollingFile name="appLog"
>                      fileName="${APP_LOG_ROOT}/SpringBoot2App/application.log"
>                      filePattern="${APP_LOG_ROOT}/SpringBoot2App/application-%d{yyyy-MM-dd}-%i.log">
>             <PatternLayout pattern="${LOG_PATTERN}" />
>             <Policies>
>                 <SizeBasedTriggeringPolicy size="1 KB" />
>             </Policies>
>             <DefaultRolloverStrategy max="20" />
>         </RollingFile>
>         <Console name="Console" target="SYSTEM_OUT" follow="true">
>             <PatternLayout pattern="${LOG_PATTERN}" />
>         </Console>
>     </Appenders>
>     <Loggers>
>         <Root level="debug">
>             <AppenderRef ref="appLog" />
>             <AppenderRef ref="Console" />
>         </Root>
>     </Loggers>
> </Configuration>
> {code}



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