logback报错no applicable action for [maxFileSize]

Logging system failed to initialize using configuration from 'classpath:logback-xxxx.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:26 - no applicable action for [maxFileSize], current ElementPath  is
[[configuration][appender][rollingPolicy][maxFileSize]]

原因分析:
报错中说明,no applicable action for [MaxFileSize],[MaxFileSize]没有找到适用的配置,查看rollingPolicy配置是class是ch.qos.logback.core.rolling.TimeBasedRollingPolicy

解决办法:
把rollingPolicy标签配置TimeBasedRollingPolicy改为SizeAndTimeBasedRollingPolicy既可支持maxFileSize,
fileNamePattern必须包含“%i”例如,假设最小值和最大值分别为1和2,命名模式为 log%i.log,会产生归档文件log1.log和log2.log

不然会报以下错误:
Logging system failed to initialize using configuration from 'classpath:logback-xxx.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2b68590b - Missing integer token, that is %i, in FileNamePattern [info.%d{yyyy-MM-dd}.log]

TimeBasedRollingPolicy与SizeAndTimeBasedRollingPolicy示例:

1、TimeBasedRollingPolicy与(根据时间的滚动策略)
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <FileNamePattern>log/log.log.%d.log</FileNamePattern>
    <maxHistory>30</maxHistory>
</rollingPolicy>

2、SizeAndTimeBasedRollingPolicy(根据时间和文件大小的滚动策略)
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
    <!-- rollover daily -->
    <fileNamePattern>log/log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
    <!-- 每个文件最多5MB,保存60天的历史记录,但最多20GB -->
    <maxFileSize>5MB</maxFileSize>
    <maxHistory>60</maxHistory>
    <totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>