resources目录下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_HOME" value="./logs" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{HH:mm:ss} |-%highlight(%-5level) [%thread]-[%file:%line]: %msg%n
</pattern>
</layout>
</appender>
<appender name="INFOFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/LeeDogEgg-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/LeeDogEgg-info.log.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<MaxFileSize>50KB</MaxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} |-%-5level [%thread]-[%file:%line]: %msg%n
</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="WARNFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/LeeDogEgg-warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/LeeDogEgg-warn.log.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<MaxFileSize>50KB</MaxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} |-%-5level [%thread]-[%file:%line]: %msg%n
</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="ERRORFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/LeeDogEgg-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/LeeDogEgg-error.log.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>240</MaxHistory>
<MaxFileSize>10MB</MaxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} |-%-5level [%thread]-[%file:%line]: %msg%n
</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="info" >
<appender-ref ref="STDOUT" />
<appender-ref ref="INFOFILE" />
<appender-ref ref="WARNFILE" />
<appender-ref ref="ERRORFILE" />
</root>
</configuration>
yml文件中指定位置
logging:
config: classpath:logbak.xml