Logging

Kafka Streams uses Apache Log4j 2 for logging service.

The main logger is org.apache.kafka.streams. Use log4j.properties to set the logging levels.

Application Logging Using log4j — log4j.properties Logging Configuration File

log4j.properties
log4j.rootLogger=INFO
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] %p %m (%c)%n

log4j.logger.org.apache.kafka.streams=DEBUG
log4j.additivity.org.apache.kafka.streams=false
Tip
Save log4j.properties in src/main/resources in your Kafka Streams application’s project.

Simple Logging Facade for Java (SLF4J)

Kafka uses Simple Logging Facade for Java (SLF4J) for logging.

Tip

Use slf4j-simple library dependency in Scala applications (in build.sbt) for basic logging where messages of level INFO and higher are printed to System.err.

build.sbt
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.8.0-alpha2"

Replace slf4j’s simple binding to switch between logging frameworks (e.g. slf4j-log4j12 for log4j).

build.sbt
val logback = "1.2.3"
libraryDependencies += "ch.qos.logback" % "logback-core" % logback
libraryDependencies += "ch.qos.logback" % "logback-classic" % logback
Note

With logback’s configuration (as described in the above tip) you may see the following messages in the logs:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jacek/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jacek/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

Commenting out logback-classic in build.sbt resolves it.

build.sbt
val logback = "1.2.3"
libraryDependencies += "ch.qos.logback" % "logback-core" % logback
//libraryDependencies += "ch.qos.logback" % "logback-classic" % logback

FIXME: Explain why the commenting out is required?

results matching ""

    No results matching ""