private static final Logger
        LOGGER = LogManager.getLogger(Log4JDefaultConfig.class);
        LOGGER.error("This is an ERROR level log message");

OUTPUT

ERROR kafka.producers.logging.Log4JDefaultConfig - This is an ERROR level log 
message!

________________________________
From: Renko Alexander P via users <[email protected]>
Sent: Friday, August 28, 2026 1:45 PM
To: [email protected] <[email protected]>
Cc: Renko Alexander P <[email protected]>
Subject: setting up log4j2 for Kafka Provider

Good Afternoon,
Am looking to control log4j2 output produced by Kafka...but am having a little 
difficultly getting this to work as expected.

During the kafka producer startup I've added this command:  
-Dlog4j2.configurationFile=/<whatever>/kafka/producers/log4j2.properties

I've created a log4j2.properties file as follows:

# Root Logger
rootLogger=INFO, STDERR

# Direct log messages to stderr
appender.console.type = Console
appender.console.name = STDERR
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] 
%C{1} - %msg%n

Yet, when I look at STDERR am not seeing the desired messages. Do I need to 
configure slf4j instead or in conjunction?  Anything I'm possibly doing wrong?

Anyone with experience on customizing kafka message logging, will to chime in?

Thank You,
--Alex

Reply via email to