spring kafka - set consumer log level manually (spring 5)

Viewed 3541

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. :)

0 Answers
Related