Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created July 20, 2023 09:21
Show Gist options
  • Save saswata-dutta/bfd8a116036388fb029e3229e69d680b to your computer and use it in GitHub Desktop.
Save saswata-dutta/bfd8a116036388fb029e3229e69d680b to your computer and use it in GitHub Desktop.
logback size and time based rolling
<configuration>
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/myapp.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>./logs/myapp-%d{yyyy-MM-dd_HH}.%i.log.gz</fileNamePattern>
<!-- keep 10 days' worth of history capped at 3GB total size -->
<maxHistory>240</maxHistory>
<maxFileSize>100MB</maxFileSize>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="ROLLING" />
</root>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment