Skip to content

SizeBasedTriggeringPolicy counter not resetting after TimeBasedTriggeringPolicy rollover #2297

@ppkarwasz

Description

@ppkarwasz

Discussed in #1842

Originally posted by RollsCorey October 6, 2023
Hello. Using log4j 2.20.0. My configuration file specifies a SizeBasedTriggeringPolicy and a TimeBasedTriggeringPolicy. My understanding is that when the log rolls due to the TimeBasedTriggeringPolicy, the counter associated with the SizeBasedTriggeringPolicy should reset to 1, but this isn't happening. It just keeps incrementing from where it left off. Here is my config file. Any ideas? Thanks in advance.

<Configuration status="warn">
    <Properties>
        <Property name="basePath">Y:/logs</Property>
    </Properties>

    <Appenders>
        <RollingFile name="fileLogger"
                     filePattern="${basePath}/log_%d{yyyyMMdd}_%i.txt">
            <PatternLayout>
                <pattern>%d{MM/dd/yy HH:mm:ss.SSS} %msg%n
                </pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="10 MB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
            <DirectWriteRolloverStrategy maxFiles="10000"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="info" additivity="false">
            <appender-ref ref="fileLogger" />
        </Root>
    </Loggers>
</Configuration>

Metadata

Metadata

Assignees

Labels

appenders:RollingAffects log file rolling functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions