logback-spring.xml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration debug="false">
  3. <!--定义日志文件的存储地址 -->
  4. <property name="LOG_HOME" value="../logs" />
  5. <!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
  6. <!-- 控制台输出 -->
  7. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  8. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  9. <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符
  10. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
  11. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
  12. </encoder>
  13. </appender>
  14. <!-- 按照每天生成日志文件 -->
  15. <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  16. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  17. <!--日志文件输出的文件名 -->
  18. <FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
  19. <!--日志文件保留天数 -->
  20. <MaxHistory>30</MaxHistory>
  21. <maxFileSize>10MB</maxFileSize>
  22. </rollingPolicy>
  23. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  24. <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
  25. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
  26. </encoder>
  27. </appender>
  28. <!-- 生成 error html格式日志开始 -->
  29. <appender name="HTML" class="ch.qos.logback.core.FileAppender">
  30. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  31. <!--设置日志级别,过滤掉info日志,只输入error日志-->
  32. <level>ERROR</level>
  33. </filter>
  34. <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  35. <layout class="ch.qos.logback.classic.html.HTMLLayout">
  36. <pattern>%p%d%msg%M%F{32}%L</pattern>
  37. </layout>
  38. </encoder>
  39. <file>${LOG_HOME}/error-log.html</file>
  40. </appender>
  41. <!-- 生成 error html格式日志结束 -->
  42. <!-- 每天生成一个html格式的日志开始 -->
  43. <appender name="FILE_HTML" class="ch.qos.logback.core.rolling.RollingFileAppender">
  44. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  45. <!--日志文件输出的文件名 -->
  46. <FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.html</FileNamePattern>
  47. <!--日志文件保留天数 -->
  48. <MaxHistory>30</MaxHistory>
  49. <MaxFileSize>10MB</MaxFileSize>
  50. </rollingPolicy>
  51. <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  52. <layout class="ch.qos.logback.classic.html.HTMLLayout">
  53. <pattern>%p%d%msg%M%F{32}%L</pattern>
  54. </layout>
  55. </encoder>
  56. </appender>
  57. <!-- 每天生成一个html格式的日志结束 -->
  58. <!--myibatis log configure -->
  59. <logger name="com.apache.ibatis" level="TRACE" />
  60. <logger name="java.sql.Connection" level="DEBUG" />
  61. <logger name="java.sql.Statement" level="DEBUG" />
  62. <logger name="java.sql.PreparedStatement" level="DEBUG" />
  63. <!-- 日志输出级别 -->
  64. <root level="INFO">
  65. <appender-ref ref="STDOUT" />
  66. <appender-ref ref="FILE" />
  67. <appender-ref ref="HTML" />
  68. <appender-ref ref="FILE_HTML" />
  69. </root>
  70. </configuration>