logback-spring.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration debug="false" scan="false">
  3. <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
  4. <property name="log.path" value="/home/app"/>
  5. <!-- 彩色日志格式 -->
  6. <property name="CONSOLE_LOG_PATTERN"
  7. value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" />
  8. <!-- Console log output -->
  9. <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
  10. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  11. <pattern>${CONSOLE_LOG_PATTERN}</pattern>
  12. </encoder>
  13. </appender>
  14. <appender name="FILE"
  15. class="ch.qos.logback.core.rolling.RollingFileAppender">
  16. <!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
  17. <!-- TimeBasedRollingPolicy: 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
  18. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  19. <!-- 活动文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
  20. <!-- 文件名:log/sys.2017-12-05.0.log -->
  21. <fileNamePattern>${log.path}/logs/system.log.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  22. <!-- 每产生一个日志文件,该日志文件的保存期限为30天 -->
  23. <maxHistory>30</maxHistory>
  24. <maxFileSize>1000MB</maxFileSize>
  25. </rollingPolicy>
  26. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  27. <pattern>${CONSOLE_LOG_PATTERN}</pattern>
  28. </encoder>
  29. <!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  30. &lt;!&ndash; maxFileSize:这是活动文件的大小,默认值是10MB,本篇设置为1KB,只是为了演示 &ndash;&gt;
  31. <maxFileSize>1KB</maxFileSize>
  32. </triggeringPolicy>-->
  33. </appender>
  34. <!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
  35. <root level="INFO">
  36. <appender-ref ref="console" />
  37. <appender-ref ref="FILE"/>
  38. </root>
  39. <logger name="com.jkcredit.invoice" level="INFO">
  40. <appender-ref ref="FILE"/>
  41. </logger>
  42. </configuration>