logs-setting.xml 1.2 KB

1234567891011121314151617181920212223242526272829
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration debug="true" scan="true" scanPeriod="30 seconds">
  3. <!-- 定义日志文件的存储地址 -->
  4. <property name="LOG_HOME" value="./logs" />
  5. <!-- 控制台日志输出 -->
  6. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  7. <encoder>
  8. <pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
  9. </encoder>
  10. </appender>
  11. <!-- 按照每天日期存储日志 -->
  12. <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  13. <file>${LOG_HOME}/myapp.log</file>
  14. <encoder>
  15. <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
  16. </encoder>
  17. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  18. <fileNamePattern>${LOG_HOME}/archived/myapp-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  19. <maxHistory>10</maxHistory>
  20. <maxFileSize>10MB</maxFileSize>
  21. </rollingPolicy>
  22. </appender>
  23. <!-- 设置日志级别 -->
  24. <root level="info">
  25. <appender-ref ref="STDOUT" />
  26. <appender-ref ref="FILE" />
  27. </root>
  28. </configuration>