1234567891011121314151617181920212223242526272829 |
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration debug="true" scan="true" scanPeriod="30 seconds">
- <!-- 定义日志文件的存储地址 -->
- <property name="LOG_HOME" value="./logs" />
- <!-- 控制台日志输出 -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
- </encoder>
- </appender>
- <!-- 按照每天日期存储日志 -->
- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${LOG_HOME}/myapp.log</file>
- <encoder>
- <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${LOG_HOME}/archived/myapp-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <maxHistory>10</maxHistory>
- <maxFileSize>10MB</maxFileSize>
- </rollingPolicy>
- </appender>
- <!-- 设置日志级别 -->
- <root level="info">
- <appender-ref ref="STDOUT" />
- <appender-ref ref="FILE" />
- </root>
- </configuration>
|