<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <include resource="org/springframework/boot/logging/logback/defaults.xml"/> <springProperty name="TRACK_PATH" source="track.path"/> <!-- console --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSSXXX} %-5p TID: %36X{traceId} %-40.40logger{39} : %m%n </pattern> <charset>utf-8</charset> </encoder> </appender> <!-- 文件输出 --> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 滚动策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 滚动文件名模式 --> <fileNamePattern>${TRACK_PATH}/track.log.%d{yyyy-MM-dd}</fileNamePattern> <!-- 保留的历史文件数 --> <maxHistory>30</maxHistory> </rollingPolicy> <!-- 日志输出格式 --> <encoder> <pattern>%msg%n</pattern> </encoder> </appender> <root level="info"> <appender-ref ref="STDOUT"/> </root> <logger name="track" level="info" additivity="false"> <appender-ref ref="FILE"/> </logger> </configuration>
track: path: /Users/a58/projcets/communication/logs
标签:xml,%-,track,spring,yyyy,logback From: https://www.cnblogs.com/namedlxd/p/18408189