[logback-user] Rolling files on Android

Tony Trinh tony19 at gmail.com
Sun Dec 7 00:29:23 CET 2014


Chris,

To help troubleshoot rollover issues, you can enable logback debug
statements with:

           LoggerContext context = (LoggerContext)
LoggerFactory.getILoggerFactory();

        // Enable debugging to show rollover status
        OnConsoleStatusListener.addNewInstanceToContext(context);

This will print any status messages when logback attempts to rollover the
file.

See the working example that demonstrates the RollingFileAppender:
https://github.com/tony19/logback-examples/blob/master/logback-android/rolling-file-appender/app/src/main/java/com/github/tony19/rollingfileappender/MainActivity.java#L93

Tony


On Tue, Dec 2, 2014 at 5:48 PM, Chris Kelly <chris at thursby.com> wrote:

> I've gone through a bit of trial and error, and have not been able to get
> logs to roll over, no matter how aggressively I set up triggering and
> rolling policies.
> My intent is to have daily logs with a max size all configured in code,
> thus no assets/logback.xml.
>
> I've enabled debugging and the only status message is (which I would
> expect):
>         I/System.out﹕ 17:37:13,194 |-INFO in
> ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource
> [assets/logback.xml]
>
> In a nutshell I have the TimeBasedRollingPolicy set up to use a file as
>
> rollingPolicy.setFileNamePattern(ctx.getCacheDir().getAbsolutePath() +
> File.separator + "logs" + File.separator + name +".%d{yyyy-MM-dd_HH}.log");
> // exprimenting with hourly
> and the size based triggering at 25k like
>         sizeTriggerPolicy.setMaxFileSize("25KB");
>
> I then set these to the rollingFileAppender, set up a pattern encoder and
> add it, then start the appender.
> I can see the messages in my log file as expected, but it continues to
> grow well past the max size and past any time based trigger (even while log
> events continue).
>
> Any suggestions?
>
> Thanks,
> Chris
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20141206/8127c886/attachment.html>


More information about the Logback-user mailing list