Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3640

@Plugin not compatible between 2.x and 3.x

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 3.0.0
    • None
    • Plugins
    • None

    Description

      I had an issue with resolving Log4j2 2.19.0 as a module. While I resolved the issue by adding an explicit --add-opens clause, I still found something that appears to be an issue.

      According to this comment from rgoers,

      Plugins should NOT need to be recompiled


      Because of an earlier comment on my question I had tried to use version 3.0.0-SNAPSHOT. That produced some compiler errors. While some were easy enough to solve to be compatible with versions 2.19.0 and 3.0.0-SNAPSHOT, the moved @Plugin annotation meant I couldn't compile my project for both versions 2.19.0 and 3.0.0-SNAPSHOT. That made me believe that plugins written for 2.19.0 are not compatible with 3.0.0.

      I have created a little POC: https://github.com/robtimus/log4j-compat-test. This consists of 3 Maven modules:

      • A module with only a simple plugin
      • A module to test this plugin in Log4j2 2.19.0
      • A module to test this plugin in Log4j2 3.0.0-SNAPSHOT

      The entire project can be tested using mvn test. Right now this fails because, as expected, the moving of the @Plugin annotation caused the plugin to not be resolved.
      I've also included a "legacy" plugin class in the 3.0.0-SNAPSHOT test module that shows that the deprecated annotations org.apache.logging.log4j.core.config.plugins.PluginAttribute and org.apache.logging.log4j.core.config.plugins.PluginFactory still work; it's the (forced) replacement of org.apache.logging.log4j.core.config.plugins.Plugin with both org.apache.logging.log4j.plugins.Plugin and org.apache.logging.log4j.plugins.Configurable that causes the plugin written for version 2.19.0 to not work.


      I think that the following should be done, to prevent forcing people rewrite all of their existing plugins:

      • Re-adding the org.apache.logging.log4j.core.config.plugins.Plugin annotation, but make it deprecated.
      • The plugin registration code should treat this plugin as a combination of org.apache.logging.log4j.plugins.Plugin and org.apache.logging.log4j.plugins.Configurable. There may be another one, for the category attribute of the old annotation, but I couldn't find out which one yet.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Spoor Rob Spoor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: