Ken Huang created KAFKA-21460:
---------------------------------
Summary: Docker root log level overrides discard existing Log4j2
appender references
Key: KAFKA-21460
URL: https://issues.apache.org/jira/browse/KAFKA-21460
Project: Kafka
Issue Type: Bug
Reporter: Ken Huang
Setting {{KAFKA_LOG4J_ROOT_LOGLEVEL}} or {{KAFKA_TOOLS_LOG4J_LOGLEVEL}}
replaces the entire Log4j2 {{Root}} configuration with an object containing
only {{{}level{}}}. As a result, existing {{AppenderRef}} entries and other
{{Root}} settings are lost.
For example, setting {{KAFKA_LOG4J_ROOT_LOGLEVEL=DEBUG}} changes:
{{Root:
level: INFO
AppenderRef:
- ref: STDOUT
- ref: KafkaAppender}}
to:
{code:java}
Root:
level: DEBUG
{code}
h3. Steps to Reproduce
# Run {{KafkaDockerWrapper setup}} in the JVM Docker image with
{{{}KAFKA_LOG4J_ROOT_LOGLEVEL=DEBUG{}}}, without mounting any custom
configuration files.
# Inspect {{Configuration.Loggers.Root}} in
{{{}/opt/kafka/config/log4j2.yaml{}}}.
# Compare it with the default configuration in
{{{}/etc/kafka/docker/log4j2.yaml{}}}.
Only the root logger level should change, while existing appender references
and other {{Root}} settings remain intact. However, the generated {{Root}}
configuration currently contains only {{{}level{}}}, which can prevent log
messages from being written to stdout or {{{}server.log{}}}. The same issue
occurs in {{tools-log4j2.yaml}} when {{KAFKA_TOOLS_LOG4J_LOGLEVEL}} is set.
Both paths use {{{}KafkaDockerWrapper.overrideLog4jConfigByEnv{}}}, which
currently replaces the entire {{Root}} object instead of updating only its
{{{}level{}}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)