logback-spring.xml 配置cron定时器给出完整的logback-spring.xml配置
时间: 2023-03-07 10:30:11 浏览: 138
<configuration>
<springProfile name="production">
<timestamp key="byDay" datePattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/logs/appName-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
</springProfile> <springProfile name="cron">
<timestamp key="byCron" datePattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/logs/appName-cron-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
<cronTriggeringPolicy class="ch.qos.logback.core.rolling.CronTriggeringPolicy">
<cronExpression>0 0 0 * * ?</cronExpression>
</cronTriggeringPolicy>
</springProfile>
</configuration>
阅读全文