logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <property name="log.base" value="D:/logs/log_info" /> <property name="log.error" value="D:/logs/log_error" /> <jmxConfigurator /> <appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <thresholdFevel>INFO</thresholdFevel> </filter> <!-- 文件路径 --> <File>${log.base}.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 文件名称 --> <fileNamePattern>${log.base}.%d{yyyy-MM-dd}.log.%i</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>200MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- 最大保存十天的日志 --> <maxHistory>10</maxHistory> </rollingPolicy> <encoder> <pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern> <charset>UTF-8</charset> </encoder> </appender> <appender name="logfilerror" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <thresholdFevel>ERROR</thresholdFevel> <onMismatch>DENY</onMismatch> <onMatch>ACCEPT</onMatch> </filter> <File>${log.error}.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.error}.%d{yyyy-MM-dd}.log.%i</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>200MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <maxHistory>10</maxHistory> </rollingPolicy> <encoder> <pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern> <charset>UTF-8</charset> </encoder> </appender> <logger name="baoming" level="INFO" /> <root> <level value="INFO" /> <appender-ref ref="logfile" /> <appender-ref ref="logfilerror" /> </root> </configuration>