在logback-spring.xml配置文件中添加如下配置:
<appender name="OPR_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.path}/opr.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.path}/opr.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p ${PID:- } [%15.15t] [%-39logger{39}] [%X{TRACE_ID}] - %m%n%wEx</pattern> </encoder> </appender> <logger name="com.sky.opr" additivity="true"> <appender-ref ref="OPR_LOG" /> </logger>