关于日志的指定输出,麻烦大大看看

提问 1 3159
liaosq
liaosq 2018-12-05
版本:renren-security 开发环境:
日志配置文件是这样的 , 现在想改成 按照指定cron表达式 (如 每小时) 输出至txt文件 (如 2018-12-5-12:00_log.txt) ,该如何配置捏 , 请大大帮忙看看img[//cdn.renren.io/ddb94201812051153057299.png]
本帖标签: renren-security logback
回帖
  • 世纪末
    2019-01-02
    生产在用的,给你参考。springboot 2.0.3 可以去看一下SizeAndTimeBasedRollingPolicy这个类 [pre] <?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml"/> <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${LOG_PATH}${LOG_FILE}</File> <encoder> <pattern>${FILE_LOG_PATTERN}</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}daily/${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern> <maxHistory>180</maxHistory> <maxFileSize>200MB</maxFileSize> </rollingPolicy> </appender> <springProfile name="dev"> <root level="INFO"> <appender-ref ref="FILE"/> <appender-ref ref="CONSOLE"/> </root> </springProfile> <!-- 环境配置 --> <springProfile name="test"> <root level="INFO"> <appender-ref ref="FILE"/> <!--<appender-ref ref="CONSOLE"/>--> </root> </springProfile> <!-- 生产环境. --> <springProfile name="prod"> <root level="INFO"> <appender-ref ref="FILE"/> </root> </springProfile> </configuration> [/pre]
    1 回复