logback-spring.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~ Copyright (c) 2018-2025, hnqz All rights reserved.
  4. ~
  5. ~ Redistribution and use in source and binary forms, with or without
  6. ~ modification, are permitted provided that the following conditions are met:
  7. ~
  8. ~ Redistributions of source code must retain the above copyright notice,
  9. ~ this list of conditions and the following disclaimer.
  10. ~ Redistributions in binary form must reproduce the above copyright
  11. ~ notice, this list of conditions and the following disclaimer in the
  12. ~ documentation and/or other materials provided with the distribution.
  13. ~ Neither the name of the pig4cloud.com developer nor the names of its
  14. ~ contributors may be used to endorse or promote products derived from
  15. ~ this software without specific prior written permission.
  16. ~ Author: hnqz
  17. -->
  18. <!--
  19. 小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
  20. <properties>
  21. <log-path>/Users/hnqz</log-path>
  22. </properties>
  23. 1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
  24. 2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
  25. -->
  26. <configuration debug="false" scan="false">
  27. <property name="log.path" value="logs/${project.artifactId}"/>
  28. <!-- 彩色日志格式 -->
  29. <property name="CONSOLE_LOG_PATTERN"
  30. value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
  31. <!-- 彩色日志依赖的渲染类 -->
  32. <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
  33. <conversionRule conversionWord="wex"
  34. converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
  35. <conversionRule conversionWord="wEx"
  36. converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
  37. <!-- Console log output -->
  38. <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
  39. <encoder>
  40. <pattern>${CONSOLE_LOG_PATTERN}</pattern>
  41. </encoder>
  42. </appender>
  43. <!-- Log file debug output -->
  44. <appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
  45. <file>${log.path}/debug.log</file>
  46. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  47. <fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  48. <maxFileSize>50MB</maxFileSize>
  49. <maxHistory>30</maxHistory>
  50. </rollingPolicy>
  51. <encoder>
  52. <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
  53. </encoder>
  54. </appender>
  55. <!-- Log file error output -->
  56. <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
  57. <file>${log.path}/error.log</file>
  58. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  59. <fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  60. <maxFileSize>50MB</maxFileSize>
  61. <maxHistory>30</maxHistory>
  62. </rollingPolicy>
  63. <encoder>
  64. <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
  65. </encoder>
  66. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  67. <level>ERROR</level>
  68. </filter>
  69. </appender>
  70. <logger name="org.activiti.engine.impl.db" level="DEBUG">
  71. <appender-ref ref="debug"/>
  72. </logger>
  73. <!--nacos 心跳 INFO 屏蔽-->
  74. <logger name="com.alibaba.nacos" level="OFF">
  75. <appender-ref ref="error"/>
  76. </logger>
  77. <!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
  78. <root level="INFO">
  79. <appender-ref ref="console"/>
  80. <appender-ref ref="debug"/>
  81. </root>
  82. </configuration>