[ 
https://issues.apache.org/jira/browse/LOG4J2-3640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17645445#comment-17645445
 ] 

Ralph Goers edited comment on LOG4J2-3640 at 12/9/22 6:53 PM:
--------------------------------------------------------------

There probably aren't as many plugins as you think that don't use it. If you 
compile without module-info.java the compiler will use any annotation processor 
it finds on the classpath. Since the annotation processor is in log4j-core in 
2.0 almost everything will use it. Once you add a module-info.java Maven sets 
things up to use the module path instead and so you have to manually declare 
the annotation processor.  With Log4j 3.0 we separated the annotation processor 
into its own jar so any artifact that creates Log4j plugins should use it.

Given that JPMS is not extremely popular yet I suspect we won't run into too 
many issues. But we do need to do a better job of documenting that package 
scanning is not recommended.


was (Author: [email protected]):
There probably aren't as many plugins as you think that don't use it. If you 
compile without module-info.java the compiler will use any annotation processor 
it finds on the classpath. Since the annotation processor is in log4j-core in 
2.0 almost everything will use it. Once you add a module-info.java Maven sets 
things up to use the module path instead and so you have to manually declare 
the annotation processor.  With Log4j 3.0 we separated the annotation processor 
into its own jar so any artifact that creates Log4j plugins should use it.

Given that JPMS is not extremely popular yet I suspect we won't run into too 
many issues.

> @Plugin not compatible between 2.x and 3.x
> ------------------------------------------
>
>                 Key: LOG4J2-3640
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3640
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Plugins
>    Affects Versions: 3.0.0
>            Reporter: Rob Spoor
>            Priority: Major
>
> 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|https://stackoverflow.com/questions/74592131/maven-log4j-class-not-found#comment131670094_74592131]
>  from [~rgoers], {quote}Plugins should NOT need to be recompiled
> {quote}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to