我创建了带有附加程序的 loggback.xml:
<appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<file>logs/nfp-server.log</file>-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>D:/logs/archived/log_%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>10KB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>20MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<springProfile name="local">
<logger name="nfp" level="WARN" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ROLLING-FILE"/>
</logger>
</springProfile>
<springProfile name="prod">
<logger name="nfp" level="WARN" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ROLLING-FILE"/>
</logger>
</springProfile>
在弹簧属性中:
#loging
logging.file=D:/logs/nfp-server_local.log
我希望将每个大于 10KB 的日志文件移至存档。但是当我启动服务器时,D:/logs
我有这个:
-logs
-nfp-server_local.log (int this file all logs, 48KB)
-archived
-log_2018-04-02.0.txt (0 byte)