Java – Logback roll only on file size


I am using logback 1.0.13. I want my log file to roll solely based off of file size. If this takes 2 hours or 2 years, I don't care. I am having trouble figuring out how to do so. My appender is configured like so:

<appender name="serverFaultFile"
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <pattern>[%p] [%d{ISO8601}] [%c] [%m]%n</pattern>

This solution rolls monthly, which isn't what I need. I tried completely dropping the -%d{dateformat} modifier, but then the file was never even created/logged to. I tried modifiers %G and %yyyy, but monthly was as fine grained as logback would apparently allow me to get (see this bug report). What am I missing?

Best Solution

You want a SizeBasedTriggeringPolicy:, probably combined with a FixedWindowRollingPolicy.

Was a comment before, not sure it deserves it's own answer, but here it is. ;)

Related Question