Can we disable log4j logs only for kafka

10,588

Solution 1

you need to disable logger for both log4j and slf4j to disable kafka logging completely:

Add a logback.xml file in your resources dir:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml" />
    <logger name="org.springframework" level="OFF"/>
    <logger name="org.apache" level="OFF"/>
    <logger name="kafka" level="OFF"/>
</configuration>

Add below to your application.yaml / properties:

logging:
  level:
    root: OFF
    org.springframework: OFF
    org.apache: OFF
    kafka: OFF

Solution 2

You need to set the log level to OFF by adding this line:

log4j.logger.org.apache.kafka=OFF

Compare: How to disable loggers of a class or of whole package?

Share:
10,588

Related videos on Youtube

babravahan
Author by

babravahan

Updated on September 14, 2022

Comments

  • babravahan
    babravahan over 1 year

    i am using following log4j.properties

    log4j.rootLogger=DEBUG, stdout
    
    
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
    

    I wanted to disable log messages for kafka only. where as display my log messages being logged.