[logback-dev] [JIRA] (LOGBACK-1310) TimeBasedRollingPolicy property totalSizeCap perform bad

QOS.CH (JIRA) noreply-jira at qos.ch
Wed Jun 7 08:51:00 CEST 2017


finalmachine created LOGBACK-1310:
-------------------------------------

             Summary: TimeBasedRollingPolicy property totalSizeCap perform bad
                 Key: LOGBACK-1310
                 URL: https://jira.qos.ch/browse/LOGBACK-1310
             Project: logback
          Issue Type: Bug
          Components: logback-classic
    Affects Versions: 1.2.3
         Environment: windows 7 x64

Java 8u131
            Reporter: finalmachine
            Assignee: Logback dev list
         Attachments: pic1.PNG

I use this appender

<{color:#000080}appender {color}{color:#0000ff}name{color}{color:#008000}="test" {color}{color:#0000ff}class{color}{color:#008000}="ch.qos.logback.core.rolling.RollingFileAppender">{color}

    <{color:#000080}prudent{color}>true</{color:#000080}prudent{color}>

    <{color:#000080}rollingPolicy {color}{color:#0000ff}class{color}{color:#008000}="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"{color}>

        <{color:#000080}fileNamePattern{color}>./logs/free-%d\{yyyy-MM-dd}.log</{color:#000080}fileNamePattern{color}>

        <{color:#000080}cleanHistoryOnStart{color}>true</{color:#000080}cleanHistoryOnStart{color}>

        <{color:#000080}maxHistory{color}>30</{color:#000080}maxHistory{color}>

        <{color:#000080}totalSizeCap{color}>70MB</{color:#000080}totalSizeCap{color}>

    </{color:#000080}rollingPolicy{color}>

    <{color:#000080}encoder{color}>

        <{color:#000080}pattern{color}>%d\{yyyy-MM-dd HH:mm:ss} [%thread] (%level) %C(%F:%L) %n%msg%n</{color:#000080}pattern{color}>

    </{color:#000080}encoder{color}>

</{color:#000080}appender{color}>

then I write a test java code

{color:#333333}public static void main(String[] args) \{{color}
 {color:#333333}     Logger logger = LoggerFactory.getLogger("test");{color}
 {color:#333333}     for (int i = 0; i < 1000000; i++) \{{color}
 {color:#333333}         logger.info(UUID.randomUUID().toString());{color}
 {color:#333333}     }{color}
 }

I run the program first time,It give me a logger file 114MB,it is very sad because the size is great than 70MB as conf file.

{color:#333333}in the [https://logback.qos.ch/manual/appenders.html] you say the "total size cap" restriction applied second.{color}

so I delete some log to make the log file size 12MB, and I rename the file name as it is created yesteday, then I run the java program again, when total size great than 70MB, the old log file is not delete, and the result is in Attachment pic1.PNG.

 

I‘d like discuss the requrement of {color:#008000}TimeBasedRollingPolicy{color}, I use it to split log by day, at the same time prevent the total log file great than the disk size or the server will wrong, so I need logback to hold all files which macthes {color:#000080}fileNamePattern{color} within disk size.

now I just use SizeAndTimeBasedRollingPolicy, but I dislike the %i.

So maybe this bug is more like a new feather, Hope logback do better.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list