Debugging

Debugging setups with the Apache Pekko Connectors Kafka Connector will be required at times. This page collects a few ideas to start out with in case the connector does not behave as you expected.

Logging with SLF4J

Apache Pekko, Apache Pekko Streams and thus the Apache Pekko Connectors Kafka Connector support SLF4J logging API by adding Apache Pekko’s SLF4J module and an SLF4J compatible logging framework, eg. Logback.

The Kafka client library used by the Apache Pekko Connectors Kafka connector uses SLF4J, as well.

Maven
<properties>
  <pekko.version>1.1.1</pekko.version>
  <scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-slf4j_${scala.binary.version}</artifactId>
    <version>${pekko.version}</version>
  </dependency>
  <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
  </dependency>
</dependencies>
sbt
val PekkoVersion = "1.1.1"
libraryDependencies ++= Seq(
  "org.apache.pekko" %% "pekko-slf4j" % PekkoVersion,
  "ch.qos.logback" % "logback-classic" % "1.2.3"
)
Gradle
def versions = [
  PekkoVersion: "1.1.1",
  ScalaBinary: "2.13"
]
dependencies {
  implementation "org.apache.pekko:pekko-slf4j_${versions.ScalaBinary}:${versions.PekkoVersion}"
  implementation "ch.qos.logback:logback-classic:1.2.3"
}

To enable Apache Pekko SLF4J logging, configure Apache Pekko in application.conf as below. Refer to the Pekko documentation for details.

pekko {
  loggers = ["org.apache.pekko.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
  logging-filter = "org.apache.pekko.event.slf4j.Slf4jLoggingFilter"
}

Receive logging

In case you’re debugging the internals in the Kafka Consumer actor, you might want to enable receive logging to see all messages it receives. To lower the log message volume, change the Kafka poll interval to something larger, eg. 300 ms.

pekko {
  actor {
    debug.receive = true
  }
  kafka.consumer {
    poll-interval = 300ms
  }
}