We are working on spring
project and integrated with spring-kafka
recently. It's working as expected where we are able produce and consume messages properly.
But as we moved project to PROD, we are getting DEBUG level log statements and amount of statements overwhelmed. We are trying to set logging levels to WARN or ERROR specifically for Kafka logs.
In process we added logback.xml
(added in main/resources) by following below article but no luck, also tried other solutions we came across in internet. (adding log4j.properties and log4j2.xml)
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration name="default">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.apache.kafka" level="error" />
<logger name="org.apache.kafka.common.metrics" level="error"/>
<logger name="org.apache.kafka.clients" level="error"/>
<logger name="org.apache.kafka.clients.consumer.internals" level="error"/>
<logger name="org.apache.kafka.clients.consumer.internals.Fetcher" level="error"/>
<root level="error" name="org.apache.kafka" additivity="false">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Sample logs:
[org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] INFO org.apache.kafka.clients.Metadata - [Consumer clientId=client-01, groupId=publisher] Cluster ID: Udhjf-fdbfds
[org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] INFO org.apache.kafka.clients.consumer.internals.AbstractCoordinator - [Consumer clientId=client-01, groupId=publisher] Discovered group coordinator 127.....0 (id: 65654654654 rack: null)
[org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] INFO org.apache.kafka.clients.consumer.internals.AbstractCoordinator - [Consumer clientId=client-01, groupId=publisher] (Re-)joining group
[WebSphere non-WLM Dispatch Thread t=008abcf0] WARN org.apache.kafka.clients.consumer.ConsumerConfig - The configuration 'schema.registry.url' was supplied but isn't a known config.
[WebSphere non-WLM Dispatch Thread t=008abcf0] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka version: 2.7.1
[WebSphere non-WLM Dispatch Thread t=008abcf0] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka commitId: 616tyu85d0d567566
Anyone came across similar situation or any leads will be really helpful. Thanks in advance. :)
application.properties/yml
?logging.level.org.apache.kafka=warn
? docs.spring.io/spring-boot/docs/current/reference/html/… – Bereavelog4j.logger.org.apache.kafka=warn
in log4j.proerties. could you please suggest any other way with spring.. – Kentkentalog4j.properties
(I assume your post as a typo and is missing thej
). You may also need to modify your websphere logging configs – Diddlelog4j2
file, notlog4j
. The file shown in the question is for logback, though – Diddledebug="true"
to the opening<configuration>
. With log4j2 it'sstatus="debug"
logging.apache.org/log4j/2.x/manual/configuration.html – Bereavelogging.level.org.apache.kafka: INFO
@GaryRussell, It’s work for me, using Spring Boot 3.2.6 in application.yaml, thanks 🙏🏼 – Works