logback中设置maxHistory属性无效?

steemit 发布于 2013/02/18 18:00
阅读 7K+
收藏 0
logback指定maxHistory,按照文档中说明测试,发现过期的日志归档文件并不能被删除:
The optional maxHistory property controls the maximum number of archive files to keep, deleting older files. For example, if you specify monthly rollover, and set maxHistory to 6, then 6 months worth of archives files will be kept with files older than 6 months deleted. Note as old archived log files are removed, any folders which were created for the purpose of log file archiving will be removed as appropriate.
路过的大虾给看看.
<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logFile.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <!-- daily rollover -->
      <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>

      <!-- keep 30 days' worth of history -->
      <maxHistory>30</maxHistory>
    </rollingPolicy>

    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender> 

  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>
加载中
0
凯文加内特
凯文加内特
少个file配置
0
把酒言欢520
把酒言欢520

我也出现了这种 rollingPolicy 不能自动清理 归档日志的问题,超过了 maxHistory 的数量 不会自动删除

0
隆回水哥
隆回水哥

maxHistory  是文件数量

0
l
lmlx
<maxHistory>4</maxHistory>

如果这么设置,按天来创建日志,是删除4天前的日志吗

返回顶部
顶部