简体   繁体   English

Kafka:如何启用客户端日志记录?

[英]Kafka: How do I enable client logging?

When I instantiate a Kafka consumer 当我实例化Kafka消费者时

KafkaConsumer<String,String> consumer = new KafkaConsumer<String,String>(props);

I get this message 我收到这条消息

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

How do I enable logging for my client program? 如何为客户端程序启用日志记录?

Add this property file src/main/resources/log4j.properties to your project: 将此属性文件src/main/resources/log4j.properties到您的项目:

$ cat src/main/resources/log4j.properties 
# Root logger option
log4j.rootLogger=DEBUG, stdout

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

This will enable logging. 这将启用日志记录。 You can then set the standard options such as debug level, output format, etc, as per the logging documentation. 然后,您可以根据日志记录文档设置标准选项,如调试级别,输出格式等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用log4j启用Kafka日志记录 - How to enable Kafka logging with log4j 如何更改 Kafka 客户端日志记录级别/首选项? - How to change the Kafka client logging levels/preferences? 如何为Google Closure Compiler启用日志记录? - How do I enable logging for Google Closure Compiler? 使用Jersey客户端时如何获得有用的日志记录? - How do I get useful logging when using the Jersey client? Apache Solr 客户端 = 如何启用“有线”日志记录(使用 log4j) - Apache Solr Client = How to enable “wire” logging (with log4j) log4j:如何在超类中为方法启用子类中的日志记录 - log4j: How do I enable logging in a subclass for a method in a superclass 使用log4j进行Spring Boot日志记录-如何启用Spring Boot日志条目? - Spring boot logging with log4j - how do I ENABLE spring boot log entries? 如何通过命令行启用有关垃圾收集的详细信息的日志记录? - How do I enable logging of detailed information about garbage collection through the command line? 如何为 Spring Security SAML 示例应用程序启用调试日志记录? - How do I enable debug logging for the Spring Security SAML sample app? 如何在码头启用登录? - How to enable logging in jetty?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM