Search code examples
javagroovylogbacklogback-groovy

Using Logback with RollingFilePolicy in groovy


I'm trying to configure logback(in groovy) with a daily rollover policy. This is the configuration for my appender

appender("FILE", RollingFileAppender) {

    encoder(PatternLayoutEncoder) {
        pattern = "%d{HH:mm:ssZ} [%thread] %-5level %logger{100} - %msg%n"
    }

    /* Today's log file */
    file = "./logs/log.log"
    append = true

    /* Rollover policy */
    rollingFilePolicy(TimeBasedRollingPolicy) {
        fileNamePattern = "./logs/archived/%d{yyyy, aux}/%d{MM, aux}/log_%d{yyyy-MM-dd}.zip"
        maxHistory = 180
    }

    filter(ThresholdFilter) {
        level = INFO
    }
}

When I try to run the application, however, I see the following problem and the log files are not created.

Appender [FILE] of type [ch.qos.logback.core.rolling.RollingFileAppender] has no appplicable [rollingFilePolicy] property

Can someone help me out here? I guess there's a configuration problem. I would have used the translator program on the logback site, but it's down.


Solution

  • Maybe the problem lies in the fact that it has rollingPolicy not rollingFilePolicy?