logback-spring.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <property name="PATH" value="./log"/>
  4. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  5. <encoder>
  6. <Pattern>%d %highlight(%-5level) %magenta([%thread]) %cyan(%logger:%line) %msg%n</Pattern>
  7. <charset>UTF-8</charset>
  8. </encoder>
  9. </appender>
  10. <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  11. <file>${PATH}/trace.log</file>
  12. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  13. <!-- rollover daily -->
  14. <fileNamePattern>${PATH}/trace.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  15. <!-- each file should be at most 10MB, keep 60 days worth of history, but at most 20GB -->
  16. <maxFileSize>10MB</maxFileSize>
  17. <maxHistory>60</maxHistory>
  18. <totalSizeCap>20GB</totalSizeCap>
  19. </rollingPolicy>
  20. <encoder>
  21. <Pattern>%d %highlight(%-5level) %magenta([%thread]) %cyan(%logger:%line) %msg%n</Pattern>
  22. <charset>UTF-8</charset>
  23. </encoder>
  24. </appender>
  25. <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  26. <file>${PATH}/error.log</file>
  27. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  28. <!-- rollover daily -->
  29. <fileNamePattern>${PATH}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  30. <!-- each file should be at most 10MB, keep 60 days worth of history, but at most 20GB -->
  31. <maxFileSize>10MB</maxFileSize>
  32. <maxHistory>60</maxHistory>
  33. <totalSizeCap>20GB</totalSizeCap>
  34. </rollingPolicy>
  35. <encoder>
  36. <Pattern>%d %-5level [%thread] %logger:%line %msg%n</Pattern>
  37. <charset>UTF-8</charset>
  38. </encoder>
  39. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  40. <level>ERROR</level>
  41. <onMatch>ACCEPT</onMatch>
  42. <onMismatch>DENY</onMismatch>
  43. </filter>
  44. </appender>
  45. <root level="INFO">
  46. <appender-ref ref="STDOUT"/>
  47. </root>
  48. <root level="TRACE">
  49. <appender-ref ref="TRACE_FILE"/>
  50. </root>
  51. <root level="ERROR">
  52. <appender-ref ref="ERROR_FILE"/>
  53. </root>
  54. </configuration>