Skip to content

Commit

Permalink
Merge pull request #20268 from cescoffier/reduce-kafka-log
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier authored Sep 21, 2021
2 parents 8cc9513 + 9e61373 commit 7abdd3b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/src/main/asciidoc/kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -125,6 +127,16 @@ FeatureBuildItem feature() {
return new FeatureBuildItem(Feature.KAFKA_CLIENT);
}

@BuildStep
void logging(BuildProducer<LogCategoryBuildItem> 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<NativeImageSecurityProviderBuildItem> additionalProviders) {
for (String provider : SASL_PROVIDERS) {
Expand Down

0 comments on commit 7abdd3b

Please sign in to comment.