您现在的位置是:网站首页>>信息浏览 文章详情

配置日志文件去掉Kafka的调式信息
2019-02-25 18:41 许多年以后 1575

之前在用kafka读取数据时,控制台一直有debug信息在刷屏,那我们可以在日志配置文件中这样配置去掉debug信息。

  1. <logger name="com.kafka.ighack.Consumer" level="debug" additivity="false" ></logger>
  2. <logger name="org.apache.kafka" level="OFF" additivity="false" ></logger>
  3. <logger name="io.netty" level="OFF" additivity="false" ></logger>
  4. <logger name="com.lambdaworks.redis" level="OFF" additivity="false" ></logger>

只需要这日志配置文件中添加这几句就行,目前用的时logback日志文件。
`

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  4. <encoder>
  5. <pattern>%d-%-5level:-%msg%n</pattern>
  6. </encoder>
  7. </appender>
  8. <appender name="kafkaProducer" class="ch.qos.logback.core.FileAppender">
  9. <file>./logs/kafkaProducer.log</file>
  10. <encoder>
  11. <pattern>%d %-5level [%thread] %logger{36}: %msg%n</pattern>
  12. </encoder>
  13. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  14. <level>info</level>
  15. <onMatch>ACCEPT</onMatch>
  16. <onMismatch>DENY</onMismatch>
  17. </filter>
  18. </appender>
  19. <appender name="kafkaConsumer" class="ch.qos.logback.core.FileAppender" >
  20. <file>./logs/kafkaConsumer.log</file>
  21. <append>false</append>
  22. <encoder>
  23. <pattern>%d %-5level: %msg%n</pattern>
  24. </encoder>
  25. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  26. <level>info</level>
  27. <onMatch>ACCEPT</onMatch>
  28. <onMismatch>DENY</onMismatch>
  29. </filter>
  30. </appender>
  31. <!-- TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
  32. <root level="INFO">
  33. <appender-ref ref="STDOUT"></appender>
  34. </root>
  35. <logger name="com.kafka.jmjtest.ConsumerRunnable" level="info" >
  36. <appender-ref ref="kafkaConsumer"></appender>
  37. </logger>
  38. <logger name="com.kafka.jmjtest.ProducerRunnable" level="info" >
  39. <appender-ref ref="kafkaProducer"></appender>
  40. </logger>
  41. <logger name="com.kafka.ighack.Consumer" level="debug" additivity="false" ></logger>
  42. <logger name="org.apache.kafka" level="OFF" additivity="false" ></logger>
  43. <logger name="io.netty" level="OFF" additivity="false" ></logger>
  44. <logger name="com.lambdaworks.redis" level="OFF" additivity="false" ></logger>
  45. </configuration>`
赞 (48)
文章出处:书生个人博客          转载注明下哦!o(≧v≦)o~~

标签: 原创

相似文章:


展开阅读全文
随便说两句
请先登录
遵守国家法律法规,请勿回复无意义内容,请不要回复嵌套过多的楼层!