我使用appender创建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
我想要每个日志文件&gt; 10KB移动到存档。但是当我在D:/logs
中启动服务器时,我有这个:
-logs
-nfp-server_local.log (int this file all logs, 48KB)
-archived
-log_2018-04-02.0.txt (0 byte)