diff --git a/docs/src/main/asciidoc/kafka.adoc b/docs/src/main/asciidoc/kafka.adoc index dc86da8e526dd..ba09646271789 100644 --- a/docs/src/main/asciidoc/kafka.adoc +++ b/docs/src/main/asciidoc/kafka.adoc @@ -2040,6 +2040,23 @@ private String toJson(Fruit f) { The workaround is a bit more complex as besides sending the fruits coming from Kafka, we need to send pings periodically. To achieve this we merge the stream coming from Kafka and a periodic stream emitting `{}` every 10 seconds. +== Logging + +To reduce the amount of log written by the Kafka client, Quarkus sets the level of the following log categories to `WARNING`: + +- `org.apache.kafka.clients` +- `org.apache.kafka.common.utils` +- `org.apache.kafka.common.metrics` + +You can override the configuration by adding the following lines to the `application.properties`: + +[source, properties] +---- +quarkus.log.category."org.apache.kafka.clients".level=INFO +quarkus.log.category."org.apache.kafka.common.utils".level=INFO +quarkus.log.category."org.apache.kafka.common.metrics".level=INFO +---- + == Going further This guide has shown how you can interact with Kafka using Quarkus. diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java index b1be4d68871a2..ef58f94691a16 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; +import java.util.logging.Level; import java.util.stream.Collectors; import javax.security.auth.spi.LoginModule; @@ -69,6 +70,7 @@ import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.LogCategoryBuildItem; import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; @@ -125,6 +127,16 @@ FeatureBuildItem feature() { return new FeatureBuildItem(Feature.KAFKA_CLIENT); } + @BuildStep + void logging(BuildProducer log) { + // Reduce the log level of Kafka as it tends to log a bit too much. + // See - https://github.com/quarkusio/quarkus/issues/20170 + log.produce(new LogCategoryBuildItem("org.apache.kafka.clients", Level.WARNING)); + log.produce(new LogCategoryBuildItem("org.apache.kafka.common.utils", Level.WARNING)); + log.produce(new LogCategoryBuildItem("org.apache.kafka.common.metrics", Level.WARNING)); + + } + @BuildStep void addSaslProvidersToNativeImage(BuildProducer additionalProviders) { for (String provider : SASL_PROVIDERS) {