登录中的totalSizeCap似乎未按预期工作 [英] totalSizeCap in logback doesn't seem to be working as expected

查看:417
本文介绍了登录中的totalSizeCap似乎未按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下提到的logback文件. 我想删除任何超过2天或日志大小超过500KB的日志.

I've the below mentioned logback file. I want to delete any logs older than 2 days or if the size of the logs exceed 500KB.

早于2天的日志将按预期被删除.但是,超过 500KB的日志不会被删除.我也尝试使用ch.qos.logback.core.rolling.TimeBasedRollingPolicy,但是行为是相同的.

Logs older than 2days are getting deleted as expected. However Logs which exceed 500KB are not getting deleted. I tried to use ch.qos.logback.core.rolling.TimeBasedRollingPolicy as well but the behavior is the same.

<property name="DEV_HOME" value="/home/kishore/test/logs" />

<appender name="INFO_LOG"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- <file>/home/kishore/test/logs/info.log</file> -->
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>
                 ${DEV_HOME}/info-%d{yyyy-MM-dd}.log
            </fileNamePattern>
            <totalSizeCap>500KB</totalSizeCap>
            <maxHistory>2</maxHistory>
        </rollingPolicy>
        <encoder>
            <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
            </Pattern>
        </encoder>
    </appender>

我还尝试指定了<maxFileSize>100KB</maxFileSize><fileNamePattern>${DEV_HOME}/info-%d{yyyy-MM-dd}.%i.log,因此日志将被分为100KB的多个文件. 它会按预期拆分,但是在所有日志的总大小超过500 KB之后,.0,.1等这些部分也不会被删除.

I also tried to specify <maxFileSize>100KB</maxFileSize> and <fileNamePattern>${DEV_HOME}/info-%d{yyyy-MM-dd}.%i.log, So the logs will be split into multiple files of 100KB each. It splits as expected, but neither do these parts .0, .1, etc. get deleted after the overall size of all logs reach more than 500 KB.

登录版本:1.1.3

Version of logback : 1.1.3

我缺少任何配置吗?

推荐答案

<totalSizeCap>已添加到

<totalSizeCap> was added in v1.1.7. You'll need to upgrade.

这篇关于登录中的totalSizeCap似乎未按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆