Current state: Accepted

Discussion thread: thread


Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).


KIP-653 upgrades log4j to log4j2, but some modules (i.e., tools, trogdor, shell) were omitted, since they depend on log4j-appender - as of the KIP-653 was passed (before 2.8.0), trogdor and shell were not separated from tools yet, and tools depended upon log4j-appender, since VerifiableLog4jAppender uses it. For this reason, both of log4j and log4j2 artifacts co-exist in the classpath after the upgrade.

However, as the preview build is released and tested, this approach turned out to be problematic; some users reported that when running Kafka with log4j configuration file (which is allowed for backward compatibility), the logging message is sometimes not appended properly to the logger file. This problem was resolved by removing the log4j artifacts from the classpath.

This proposal aims to deprecate log4j-appender and upgrade all the omitted modules (i.e., tools, trogdor, and shell) into log4j2 to entirely remove the log4j artifact from the classpath and avoid the problem above.

Public Interfaces

tools, trogdor, and shell module will use log4j2 instead of log4j, like other modules do in KIP-653.

Proposed Changes

1. Deprecate log4j-appender

If the user tries to use the log4j-appender, it will display a following warning message:

log4j-appender is deprecated and will be removed in a future release. For migration, please refer to the latest documentation.

2. Remove dependency on log4j-appender from the project

The tools using log4j-appender (e.g., VerifiableLog4jAppender) will be updated to use log4j2 Kafka appender instead. (We can transparently replace the dependencies since log4j2 Kafka appender uses the same format as log4j-appender.) That is, log4j-appender will be published as a part of the official release but not used by the other subprojects anymore.

The leaving modules (tools, trogdor, shell) 's slf4j, log4j 1.x dependencies will be upgraded into log4j2 and additional log4j2 configuration file will be provided. For backward compatibility, these tools will use the log4j configuration file ( by default. But for informational purpose, the following message will be shown when user launches

DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS="-Dlog4j.configurationFile=file:$base_dir/config/"'

As the message above states, the user can run the scripts with log4j2 config file by setting `export KAFKA_LOG4J_OPTS="-Dlog4j.configurationFile={log4j2-config-file-path}"`. Thanks to log4j12-api, a compatibility bridge between log4j and log4j2, the scripts can be run without any changes.

3. Provide a migration guide

We will provide a detailed migration guide to log4j2 Kafka appender for the users of the log4j-appender.

Compatibility, Deprecation, and Migration Plan

log4j-appender will be updated and published as new version releases to a certain point (perhaps, Apache Kafka 4.0) and entirely be removed from the project then. But the exact point is totally up to the community's decision.

Rejected Alternatives

Leave the omitted modules (tools, trogdor) to use log4j 1.x.

This approach has the following problems:

  1. Inconsistency: if a user wants to change the logging of tools or trogdor, they have to deal with the deprecated log4j configuration syntax; KIP-653 still supports to use of log4j configuration for backward compatibility, but it will be removed in the future.
  2. Complexity: it makes the classpath generation logic in shell scripts complex.

Provide Kafka's own log4j2-appender which succeeds log4j-appender.

It will be almost identical to the log4j2's Kafka appender; It isn’t technically worthy.

Remove VerifiableLog4jAppender from tools, and upgrade the omitted modules (tools, trogdor) to use log4j2.

To remove any existing tool, regardless of whether it is used frequently or not, we have to deprecate it first and remove it after a reasonable period of time. This approach will make the adoption of log4j2 too late.

Final Notes

As of log4j2 2.16.0, log4j2's Kafka appender ignores logging messages from 'org.apache.kafka' to prevent recursive logging. This issue is now working on progress in LOG4J2-3256 - Getting issue details... STATUS .

  • No labels