<?xml version="1.0" encoding="utf-8" ?><configuration> <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> %d - %msg%n <!-- 控制檯打印日誌文件體 時間-信息 --> </pattern> </layout> </appender> <!-- info日誌 --> <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 過濾日誌 --> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>DENY</onMatch> <!-- 若是命中就禁止這條日誌 --> <onMismatch>ACCEPT</onMismatch> <!-- 若是沒有命中就使用這條規則 --> </filter> <encoder> <pattern> %msg%n </pattern> </encoder> <!-- 滾動策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 設置info日誌路徑 --> <fileNamePattern>E:\\IntelliJ IDEA\\logback\\info.%d.log</fileNamePattern> </rollingPolicy> </appender> <!-- error日誌 --> <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 過濾日誌 --> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>ERROR</level> </filter> <encoder> <pattern> %msg%n </pattern> </encoder> <!-- 滾動策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 設置error日誌路徑 --> <fileNamePattern>E:\\IntelliJ IDEA\\logback\\error.%d.log</fileNamePattern> </rollingPolicy> </appender> <!-- 設置默認日誌級別爲INFO --> <root level="info"> <appender-ref ref="consoleLog"/> <appender-ref ref="fileInfoLog"/> <appender-ref ref="fileErrorLog"/> </root></configuration>