[
https://issues.apache.org/jira/browse/KAFKA-21460?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ken Huang updated KAFKA-21460:
------------------------------
Description:
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:
{code:java}
Root:
level: INFO
AppenderRef:
- ref: STDOUT
- ref: KafkaAppender{code}
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{}}}.
was:
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:
{code:java}
Root:
level: INFO
AppenderRef:
- ref: STDOUT
- ref: KafkaAppender{code}
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{}}}.
> 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
> Assignee: Ken Huang
> Priority: Minor
>
> 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:
> {code:java}
> Root:
> level: INFO
> AppenderRef:
> - ref: STDOUT
> - ref: KafkaAppender{code}
> 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)