I am trying to limit the maximum number of log files using the "totalSizeCap" element from the log. I use the spring boot application, so I include the login in it as follows:
logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <include resource="log4j/logback-${spring.profiles.active}.xml"/> </configuration>
log4j / Logback-DEV.xml
included> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <Pattern> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </Pattern> </encoder> </appender> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>/tmp//log/log.out</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>/tmp/log/log_%d{yyyy-MM-dd}.%i.out</fileNamePattern> <maxFileSize>10MB</maxFileSize> <maxHistory>1</maxHistory> <totalSizeCap>2MB</totalSizeCap> </rollingPolicy> <encoder> <charset>UTF-8</charset> <pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n </pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> <logger name="com.company" level="INFO" /> <logger name="org.springframework" level="ERROR" /> </included>
ERROR
ERROR in ch.qos.logback.core.joran.spi.Interpreter@17 :27 - no applicable action for [totalSizeCap], current ElementPath is [[configuration][appender][rollingPolicy][totalSizeCap]]
How to limit log files?
source share