logback-spring.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~ /*
  4. ~ * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
  5. ~ * <p>
  6. ~ * Licensed under the GNU Lesser General Public License 3.0 (the "License");
  7. ~ * you may not use this file except in compliance with the License.
  8. ~ * You may obtain a copy of the License at
  9. ~ * <p>
  10. ~ * https://www.gnu.org/licenses/lgpl.html
  11. ~ * <p>
  12. ~ * Unless required by applicable law or agreed to in writing, software
  13. ~ * distributed under the License is distributed on an "AS IS" BASIS,
  14. ~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. ~ * See the License for the specific language governing permissions and
  16. ~ * limitations under the License.
  17. ~ */
  18. -->
  19. <configuration debug="false" scan="false">
  20. <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
  21. <property name="log.path" value="logs/${spring.application.name}"/>
  22. <!-- 彩色日志格式 -->
  23. <property name="CONSOLE_LOG_PATTERN"
  24. 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}}"/>
  25. <!-- 彩色日志依赖的渲染类 -->
  26. <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
  27. <conversionRule conversionWord="wex"
  28. converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
  29. <conversionRule conversionWord="wEx"
  30. converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
  31. <!-- Console log output -->
  32. <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
  33. <encoder>
  34. <pattern>${CONSOLE_LOG_PATTERN}</pattern>
  35. </encoder>
  36. </appender>
  37. <!-- Log file debug output -->
  38. <appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
  39. <file>${log.path}/debug.log</file>
  40. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  41. <fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  42. <maxFileSize>50MB</maxFileSize>
  43. <maxHistory>30</maxHistory>
  44. </rollingPolicy>
  45. <encoder>
  46. <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
  47. </encoder>
  48. </appender>
  49. <!-- Log file error output -->
  50. <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
  51. <file>${log.path}/error.log</file>
  52. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  53. <fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  54. <maxFileSize>50MB</maxFileSize>
  55. <maxHistory>30</maxHistory>
  56. </rollingPolicy>
  57. <encoder>
  58. <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
  59. </encoder>
  60. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  61. <level>ERROR</level>
  62. </filter>
  63. </appender>
  64. <!--nacos 心跳 INFO 屏蔽-->
  65. <logger name="com.alibaba.nacos" level="OFF">
  66. <appender-ref ref="error"/>
  67. </logger>
  68. <!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
  69. <root level="INFO">
  70. <appender-ref ref="console"/>
  71. <appender-ref ref="debug"/>
  72. <appender-ref ref="error"/>
  73. </root>
  74. </configuration>