我想将当前日志文件存储在/logs
文件夹中,并将所有旧的已归档.gz
文件存储在/logs/archive
中。有没有一种方法可以配置logback?
答案 0 :(得分:1)
我想您可以将rolling policy
添加到appender
中:
<appender name="MAIN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/your-app-logs.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${LOG_GZ_DIR}/your-app-logs.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
<!-- keep 90 days' worth of history capped at 3GB total size -->
<maxHistory>90</maxHistory>
</rollingPolicy>
</appender>