logback.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <property name="log.dir" value="${datax.home}/log/" />
  4. <property name="perf.dir" value="${datax.home}/log_perf/" />
  5. <timestamp key="ymd" datePattern="yyyy-MM-dd"/>
  6. <timestamp key="byMillionSecond" datePattern="HH_mm_ss.SSS"/>
  7. <!-- 控制台输出 -->
  8. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  9. <Encoding>UTF-8</Encoding>
  10. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  11. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  12. </pattern>
  13. </encoder>
  14. </appender>
  15. <appender name="FILE" class="ch.qos.logback.core.FileAppender">
  16. <encoder>UTF-8</encoder>
  17. <file>${log.dir}/${ymd}/${log.file.name}-${byMillionSecond}.log</file>
  18. <append>false</append>
  19. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  20. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  21. </pattern>
  22. </encoder>
  23. </appender>
  24. <appender name="PERF" class="ch.qos.logback.core.FileAppender">
  25. <encoder>UTF-8</encoder>
  26. <file>${perf.dir}/${ymd}/${log.file.name}-${byMillionSecond}.log</file>
  27. <append>false</append>
  28. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  29. <pattern>%msg%n
  30. </pattern>
  31. </encoder>
  32. </appender>
  33. <!-- 按照每天生成日志文件(对 DataX 不适应,DataX 是一个进程一个日志) -->
  34. <!--
  35. <appender name="FILE"
  36. class="ch.qos.logback.core.rolling.RollingFileAppender">
  37. <Encoding>UTF-8</Encoding>
  38. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  39. <FileNamePattern>${log.dir}/%d{yyyy-MM-dd}/${log.file.name}-${byMillionSecond}.log</FileNamePattern>
  40. <MaxHistory>31</MaxHistory>
  41. </rollingPolicy>
  42. <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  43. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  44. </pattern>
  45. </encoder>
  46. </appender>
  47. -->
  48. <!-- 按照每天生成日志文件(给用户查看进度使用的)
  49. <appender name="USER_FILE"
  50. class="ch.qos.logback.core.rolling.RollingFileAppender">
  51. <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
  52. <evaluator>
  53. <expression>logger.endsWith("MasterContainerCollector") || null != throwable</expression>
  54. </evaluator>
  55. <OnMatch>ACCEPT</OnMatch>
  56. <OnMismatch>DENY</OnMismatch>
  57. </filter>
  58. <Encoding>UTF-8</Encoding>
  59. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  60. <FileNamePattern>${log.dir}/%d{yyyy-MM-dd}/${log.file}-user.log</FileNamePattern>
  61. <MaxHistory>31</MaxHistory>
  62. </rollingPolicy>
  63. <layout class="ch.qos.logback.classic.PatternLayout">
  64. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  65. </pattern>
  66. </layout>
  67. </appender>
  68. -->
  69. <!-- 按照每天生成日志文件(脏数据专用)
  70. <appender name="BAD_RECORD_FILE"
  71. class="ch.qos.logback.core.rolling.RollingFileAppender">
  72. <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
  73. <evaluator>
  74. <expression>logger.endsWith("StdoutPluginCollector") || null != throwable</expression>
  75. </evaluator>
  76. <OnMatch>ACCEPT</OnMatch>
  77. <OnMismatch>DENY</OnMismatch>
  78. </filter>
  79. <Encoding>UTF-8</Encoding>
  80. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  81. <FileNamePattern>${log.dir}/%d{yyyy-MM-dd}/${log.file}-badrecord.log</FileNamePattern>
  82. <MaxHistory>31</MaxHistory>
  83. </rollingPolicy>
  84. <layout class="ch.qos.logback.classic.PatternLayout">
  85. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  86. </pattern>
  87. </layout>
  88. </appender>
  89. -->
  90. <!-- 按照每天生成日志文件(给开发查看普通运行信息的)
  91. <appender name="DEV_FILE"
  92. class="ch.qos.logback.core.rolling.RollingFileAppender">
  93. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  94. <level>INFO</level>
  95. </filter>
  96. <Encoding>UTF-8</Encoding>
  97. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  98. <FileNamePattern>${log.dir}/%d{yyyy-MM-dd}/${log.file}-dev.log</FileNamePattern>
  99. <MaxHistory>30</MaxHistory>
  100. </rollingPolicy>
  101. <layout class="ch.qos.logback.classic.PatternLayout">
  102. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  103. </pattern>
  104. </layout>
  105. </appender>
  106. -->
  107. <!-- 按照每天生成日志文件(给开发查看全部调试信息的)
  108. <appender name="DEBUG_FILE"
  109. class="ch.qos.logback.core.rolling.RollingFileAppender">
  110. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  111. <level>DEBUG</level>
  112. </filter>
  113. <Encoding>UTF-8</Encoding>
  114. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  115. <FileNamePattern>${log.dir}/%d{yyyy-MM-dd}/${log.file}-debug.log</FileNamePattern>
  116. <MaxHistory>30</MaxHistory>
  117. </rollingPolicy>
  118. <layout class="ch.qos.logback.classic.PatternLayout">
  119. <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
  120. </pattern>
  121. </layout>
  122. </appender>
  123. -->
  124. <logger name="com.alibaba.datax.common.statistics.PerfRecord" level="INFO" additivity="false">
  125. <appender-ref ref="PERF" />
  126. </logger>
  127. <root level="${loglevel:-INFO}">
  128. <appender-ref ref="STDOUT" />
  129. <appender-ref ref="FILE" />
  130. <!--
  131. <appender-ref ref="USER_FILE" />
  132. <appender-ref ref="BAD_RECORD_FILE" />
  133. <appender-ref ref="DEV_FILE" />
  134. <appender-ref ref="DEBUG_FILE" />
  135. -->
  136. </root>
  137. </configuration>