A more detailed version from answer above
*. overall::

1.
Setup a simple Kafka Program (Completely from scratch)
2.
Add log4j dependency
(using Spring, so no version)
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
3.
Add the logback.xml
(same as answer above; seems like can comment out some not needed)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<!-- <logger name="org.springframework" level="WARN"/> -->
<logger name="org.apache" level="WARN"/>
<!-- <logger name="kafka" level="WARN"/> -->
</configuration>
*. note::
Add log4j dependency is needed
tried adding application.properties
/ log4j.properties
in src/main/resources
, seems not playing any effect
so, config like these didnt work for me::
#log4j.rootLogger=INFO, stdout
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
#
#log4j.logger.kafka=OFF
#log4j.logger.org.apache.kafka=OFF
#logging.level.root=OFF
#logging.level.org.springframework=OFF
#logging.level.org.apache=OFF
#logging.level.kafka=OFF
placing them in a diff folder location neither worked (eg: direct under project folder / inside src/main/java
)
I didnt find a dynamic way to add the config. (written inside programming code, instead of a file; neither in kafka config, nor in log4j getLogger)
place the file under src/main/resources
(though I am using Spring framework, I didnt use the integrated Kafka, & didnt ran it as Spring server -- just more like a normal Java application.)
(I dont know if there would be any confliction on the log4j (seems happened to me long before))