[logback-user] RollingFileAppender does not move the current log File

LEROUGE Pierre Pierre.LEROUGE at cegedim.com
Fri May 29 14:14:06 CEST 2015


Hi everyone,
I'm struggling with an weird issue on logback
I've settup programaticly a rollingFileAppender like in this stackoverflow thread : Setting Logback Appender path programmatically

<http://stackoverflow.com/questions/3803184/setting-logback-appender-path-programmatically>
But the current log file is not removed so I've got 5 archive Plus the complete log file that is still being populated.
and the archives are recalculated at every line written
here is the extract of code that instantiates the appender :
RollingFileAppender<ILoggingEvent> rfAppender = new RollingFileAppender<>();
    rfAppender.setFile(f.getAbsolutePath());
    rfAppender.setName(name);
    rfAppender.setContext(loggerContext);

    FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
    rollingPolicy.setContext(loggerContext);
    // rolling policies need to know their parent
    // it's one of the rare cases, where a sub-component knows about its parent
    rollingPolicy.setParent(rfAppender);
    rollingPolicy.setFileNamePattern(f.getAbsolutePath() + ".%i");
    rollingPolicy.start();

    SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy<>();
    triggeringPolicy.setMaxFileSize("5MB");
    triggeringPolicy.start();

    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern("%d{dd/MM/yyyy HH:mm:ss.SSS} | %-10.10thread | %-20.20logger{0} | %-5level : %msg%n");
    encoder.start();

    rfAppender.setEncoder(encoder);
    rfAppender.setRollingPolicy(rollingPolicy);
    rfAppender.setTriggeringPolicy(triggeringPolicy);
    rfAppender.start();
    logbackLogger.addAppender(rfAppender);

the logback version used :

ch.qos.logback: logback-classic: 1.1.3

It's running on Windows
I really don't know why this happened
If anyone have a hint on this behavior?

Thank you for your time,

Regards,

Pierre LEROUGE

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20150529/fc5d2661/attachment.html>


More information about the Logback-user mailing list