log4j2 - DefaultRolloverStrategy max value given 1000 but making at max 100
I have used DefaultRolloverStrategy for rolling files in which if I am giving max value less than 100 it is working ax expected that if assigned 50 it is making at max 50 files but when max set to greater than 100 like 200 or 1000 it is making at max 100 files.
Like in this case i have set max file size 1 kb so it will rollover when it file exceeds 1 kb and log.info.file.pattern is %d{yyyy-MM-dd}-%03i.log.gz so it is day based and max in defaultrolloverstrategy is 1000
<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="com.example">
<Properties>
<!-- <property name="FILE_SIZE">${bundle:application:max.file.size}</property>-->
<property name="FILE_SIZE">${sys:max.file.size:-1 KB}</property>
<property name="infoLogFileName">${sys:log.info.file.name:-./logs/app-all.log}</property>
<property name="warnLogFileName">${sys:log.warn.file.name:-./logs/app-warn.log}</property>
<property name="kafkaLogFileName">${sys:log.kafka.file.name:-./logs/app-kafka.log}</property>
<property name="infoLogFilePattern">${sys:log.info.file.pattern}</property>
<property name="warnLogFilePattern">${sys:log.warn.file.pattern}</property>
<property name="kafkaLogFilePattern">${sys:log.kafka.file.pattern}</property>
<property name="consolePatternLayout">${sys:console.pattern:-}</property>
<property name="numberOfRolloverFiles">${sys:rollover.files:-1000}</property>
<property name="logLevel">${sys:log.level:-INFO}</property>
``
</Properties>
<ThresholdFilterCustom />
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="${consolePatternLayout}" />
</Console>
<RollingFile name="infoLogFile"
fileName="${infoLogFileName}"
filePattern="${infoLogFilePattern}">
<LevelRangeFilter minLevel="FATAL" maxLevel="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level --- [%t] %logger{36} : %msg%n</pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy
size="${FILE_SIZE}" />
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="1000"/>
</RollingFile>
<RollingFile name="warnLogFile"
fileName="${warnLogFileName}"
filePattern="${warnLogFilePattern}">
<LevelRangeFilter minLevel="FATAL" maxLevel="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
开发者_开发百科 <PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level --- [%t] %logger{36} : %msg%n</pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy
size="${FILE_SIZE}" />
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="${numberOfRolloverFiles}"/>
</RollingFile>
<RollingFile name="kafkaLogFile"
fileName="${kafkaLogFileName}"
filePattern="${kafkaLogFilePattern}">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level --- [%t] %logger{36} : %msg%n</pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy
size="${FILE_SIZE}" />
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="${numberOfRolloverFiles}"/>
</RollingFile>
</Appenders>
<Loggers>
<!-- LOG everything at INFO level -->
<Root level="${logLevel}">
<AppenderRef ref="Console" />
<AppenderRef ref="infoLogFile" />
<AppenderRef ref="warnLogFile" />
</Root>
<!-- LOG "com.baeldung*" at TRACE level. This has no effect, as we're doing from command line -->
<Logger name="org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer" level="ERROR" ></Logger>
<Logger name="org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient" level="ERROR"></Logger>
<Logger name="org.springframework.kafka.support.LoggingProducerListener" level="INFO" additivity="false">
<appender-ref ref="kafkaLogFile" />
</Logger>
</Loggers>
</Configuration>
精彩评论