logback-prod.xml 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
  4. * <p>
  5. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. * <p>
  9. * http://www.gnu.org/licenses/lgpl.html
  10. * <p>
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. * -->
  17. <configuration scan="true" scanPeriod="60 seconds">
  18. <!-- 彩色日志依赖的渲染类 -->
  19. <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
  20. <conversionRule conversionWord="wex"
  21. converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
  22. <conversionRule conversionWord="wEx"
  23. converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
  24. <!-- 彩色日志格式 -->
  25. <property name="CONSOLE_LOG_PATTERN"
  26. 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}}"/>
  27. <!-- 控制台输出 -->
  28. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  29. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  30. <pattern>${CONSOLE_LOG_PATTERN}</pattern>
  31. <charset>utf8</charset>
  32. </encoder>
  33. </appender>
  34. <!-- 生成日志文件 -->
  35. <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
  36. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  37. <!-- 日志文件输出的文件名 -->
  38. <FileNamePattern>target/blade/log/info-%d{yyyy-MM-dd}.log</FileNamePattern>
  39. <!-- 日志文件保留天数 -->
  40. <MaxHistory>365</MaxHistory>
  41. </rollingPolicy>
  42. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  43. <pattern>%n%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%logger{50}] %n%-5level: %msg%n</pattern>
  44. </encoder>
  45. <!-- 日志文件最大的大小 -->
  46. <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  47. <MaxFileSize>500MB</MaxFileSize>
  48. </triggeringPolicy>
  49. <!-- 打印日志级别 -->
  50. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  51. <level>INFO</level>
  52. <onMatch>ACCEPT</onMatch>
  53. <onMismatch>DENY</onMismatch>
  54. </filter>
  55. </appender>
  56. <!-- 生成日志文件 -->
  57. <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
  58. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  59. <!-- 日志文件输出的文件名 -->
  60. <FileNamePattern>target/blade/log/error-%d{yyyy-MM-dd}.log</FileNamePattern>
  61. <!-- 日志文件保留天数 -->
  62. <MaxHistory>365</MaxHistory>
  63. </rollingPolicy>
  64. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  65. <pattern>%n%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%logger{50}] %n%-5level: %msg%n</pattern>
  66. </encoder>
  67. <!-- 日志文件最大的大小 -->
  68. <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  69. <MaxFileSize>500MB</MaxFileSize>
  70. </triggeringPolicy>
  71. <!-- 打印日志级别 -->
  72. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  73. <level>ERROR</level>
  74. <onMatch>ACCEPT</onMatch>
  75. <onMismatch>DENY</onMismatch>
  76. </filter>
  77. </appender>
  78. <!-- 日志输出级别 -->
  79. <root level="INFO">
  80. <appender-ref ref="STDOUT"/>
  81. <appender-ref ref="INFO"/>
  82. <appender-ref ref="ERROR"/>
  83. </root>
  84. <logger name="net.sf.ehcache" level="INFO"/>
  85. <logger name="druid.sql" level="INFO"/>
  86. </configuration>