logback-spring-test.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <configuration>
  3. <include resource="org/springframework/boot/logging/logback/base.xml"/>
  4. <logger name="jdbc.connection" additivity="false" level="FATAL">
  5. </logger>
  6. <logger name="jdbc.resultset" additivity="false" level="INFO">
  7. </logger>
  8. <logger name="jdbc.audit" additivity="false" level="INFO">
  9. </logger>
  10. <logger name="jdbc.sqlonly" additivity="false" level="DEBUG">
  11. </logger>
  12. <logger name="jdbc.sqltiming" additivity="false" level="info"><!--OFF -->
  13. <appender-ref ref="CONSOLE" />
  14. <appender-ref ref="FILE" />
  15. </logger>
  16. <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
  17. <property name="LOG_HOME" value="/Users/gizmo/JavaProjectsFiles/Logs/cameron_wms" />
  18. <!--<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">-->
  19. <!--<layout class="ch.qos.logback.classic.PatternLayout">-->
  20. <!--<pattern>-->
  21. <!--%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n-->
  22. <!--</pattern>-->
  23. <!--</layout>-->
  24. <!--</appender>-->
  25. <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
  26. <file>${LOG_HOME}/warewms/log_info.log</file>
  27. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  28. <level>ERROR</level>
  29. <onMatch>DENY</onMatch>
  30. <onMismatch>ACCEPT</onMismatch>
  31. </filter>
  32. <encoder>
  33. <pattern>
  34. %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
  35. </pattern>
  36. <charset>utf-8</charset>
  37. </encoder>
  38. <!--滚动策略-->
  39. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  40. <!-- 归档的日志文件的路径,例如今天是2013-12-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
  41. 而2013-12-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
  42. <fileNamePattern> ${LOG_HOME}/warewms/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  43. <maxHistory>30</maxHistory>
  44. <totalSizeCap>2GB</totalSizeCap>
  45. <!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
  46. 命名日志文件,例如log-error-2013-12-21.0.log -->
  47. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  48. <maxFileSize>2MB</maxFileSize>
  49. </timeBasedFileNamingAndTriggeringPolicy>
  50. </rollingPolicy>
  51. </appender>
  52. <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
  53. <!-- 正在记录的日志文件的路径及文件名 -->
  54. <file>${LOG_HOME}/warewms/log_error.log</file>
  55. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  56. <level>ERROR</level>
  57. </filter>
  58. <encoder>
  59. <pattern>
  60. %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
  61. </pattern>
  62. <charset>utf-8</charset>
  63. </encoder>
  64. <!--滚动策略-->
  65. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  66. <!-- 归档的日志文件的路径,例如今天是2013-12-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
  67. 而2013-12-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
  68. <fileNamePattern> ${LOG_HOME}/warewms/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  69. <maxHistory>30</maxHistory>
  70. <totalSizeCap>1GB</totalSizeCap>
  71. <!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
  72. 命名日志文件,例如log-error-2013-12-21.0.log -->
  73. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  74. <maxFileSize>2MB</maxFileSize>
  75. </timeBasedFileNamingAndTriggeringPolicy>
  76. </rollingPolicy>
  77. <!-- 追加方式记录日志 -->
  78. <append>true</append>
  79. </appender>
  80. <springProfile name="dev">
  81. <root level="info">
  82. <!--<appender-ref ref="consoleLog" />-->
  83. <appender-ref ref="fileInfoLog" />
  84. <appender-ref ref="fileErrorLog" />
  85. </root>
  86. </springProfile>
  87. <springProfile name="test">
  88. <root level="info">
  89. <!--<appender-ref ref="consoleLog" />-->
  90. <appender-ref ref="fileInfoLog" />
  91. <appender-ref ref="fileErrorLog" />
  92. </root>
  93. </springProfile>
  94. <springProfile name="prod">
  95. <root level="info">
  96. <appender-ref ref="fileInfoLog" />
  97. <appender-ref ref="fileErrorLog" />
  98. </root>
  99. </springProfile>
  100. </configuration>