You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Robert P (Jira)" <ji...@apache.org> on 2019/08/26 17:51:00 UTC
[jira] [Comment Edited] (LOG4J2-1555) TimeBasedTriggeringPolicy
seems to be off by 1
[ https://issues.apache.org/jira/browse/LOG4J2-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16916003#comment-16916003 ]
Robert P edited comment on LOG4J2-1555 at 8/26/19 5:50 PM:
-----------------------------------------------------------
I think that's because of the date conversion pattern and TimeBasedTriggeringPolicy in this:
{code:xml}
<RollingRandomAccessFile name="app_log" fileName="logs/app.log"
filePattern="logs/app-%d{yyyy-MM-dd'T'HH:mm:ss'Z'}.%i.log.gz">
<PatternLayout>
<Pattern>%m %ex%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="5" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
{code}
With the *TimeBasedTriggeringPolicy* interval="5" and the *filePattern* containing the date pattern of
{noformat}
"%{yyyy-MM-dd'T'HH:mm:ss'Z}.%i.log.gz"
{noformat}
a new file will be created every 5 seconds. So... the *%i* is reset to "1" every time.
was (Author: sometowngeek):
I think that's because of the date conversion pattern and TimeBasedTriggeringPolicy in this:
{code:xml}
<RollingRandomAccessFile name="app_log" fileName="logs/app.log"
filePattern="logs/app-%d{yyyy-MM-dd'T'HH:mm:ss'Z'}.%i.log.gz">
<PatternLayout>
<Pattern>%m %ex%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="5" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
{code}
With the *TimeBasedTriggeringPolicy* interval="5" and the *filePattern* containing the date pattern of "%{yyyy-MM-dd'T'HH:mm:ss'Z}.%i.log.gz", a new file will be created every 5 seconds. So... the *%i* is reset to "1" every time.
> TimeBasedTriggeringPolicy seems to be off by 1
> ----------------------------------------------
>
> Key: LOG4J2-1555
> URL: https://issues.apache.org/jira/browse/LOG4J2-1555
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.6.2
> Reporter: Farid Zakaria
> Priority: Major
>
> I have the following log4j2.xml config
> {code:title=log4j2.xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN" shutdownHook="disable">
> <Appenders>
> <RollingRandomAccessFile name="app_log" fileName="logs/app.log"
> filePattern="logs/app-%d{yyyy-MM-dd'T'HH:mm:ss'Z'}.%i.log.gz">
> <PatternLayout>
> <Pattern>%m %ex%n</Pattern>
> </PatternLayout>
> <Policies>
> <TimeBasedTriggeringPolicy interval="5" modulate="true"/>
> </Policies>
> <DefaultRolloverStrategy max="20"/>
> </RollingRandomAccessFile>
> </Appenders>
> <Loggers>
> <Root level="trace">
> <AppenderRef ref="app_log" level="DEBUG"/>
> </Root>
> </Loggers>
> </Configuration>
> {code}
> The time for the roll over files seem to be off by 1
> {code}
> -rw-r--r-- 1 fzakaria staff 197B Aug 29 15:33 app-2016-08-29T15:33:39Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 180B Aug 29 15:33 app-2016-08-29T15:33:44Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 183B Aug 29 15:33 app-2016-08-29T15:33:49Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 183B Aug 29 15:33 app-2016-08-29T15:33:54Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 183B Aug 29 15:34 app-2016-08-29T15:33:59Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 112B Aug 29 15:35 app-2016-08-29T15:34:04Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 112B Aug 29 15:35 app-2016-08-29T15:34:54Z.1.log.gz
> -rw-r--r-- 1 fzakaria staff 147B Aug 29 15:35 app-2016-08-29T15:35:09Z.1.log.gz
> {code}
> I would expect intervals of 0, 5, 10, 15, 20, 25... given the interval and modulate boolean.
> The code itself seems to subtract one from the calendar, but unsure why
> https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java#L172
--
This message was sent by Atlassian Jira
(v8.3.2#803003)