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 2021/06/01 08:15:00 UTC

[jira] [Comment Edited] (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=17354925#comment-17354925 ] 

Ralph Goers edited comment on LOG4J2-3101 at 6/1/21, 8:14 AM:
--------------------------------------------------------------

Well, I guess my memory isn't so good. In LOG4J2-2602 I modified the PatternProcessor to support updating the date if no time based triggering policy is specified.  However, the test for that only has %d{} specified without %i. Specifying both really doesn't make any sense as %i is used as an index to count the number of rollovers that have occurred in the time interval (if a time-based rollover policy is specified). With the pattern you have you would have %d{} change on every rollover and %i increment on every rollover, which is going to look odd. Furthermore, the max attribute on the DefaultRolloverStrategy will almost certainly not work correctly.


was (Author: ralph.goers@dslextreme.com):
Well, I guess my memory isn't so good. In LOG4J2-2602 I modified the PatternProcessor to support updating the date if no time based triggering policy is specified.  However, the test for that only has %d{} specified without %i. Specifying both really doesn't make any sense as %i is used an index to count the number of rollovers that have occurred in the time interval (if a time-based rollover policy is specified). With the pattern you have you would have %d{} change on every rollover and %i increment on every rollover, which is going to look odd. Furthermore, the max attribute on the DefaultRolloverStrategy will almost certainly not work correctly.

> 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)