You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "zeimao77 (via GitHub)" <gi...@apache.org> on 2024/04/01 02:48:40 UTC

[I] After modularization of Log4j2, loading the plugin (PluginManager. addPackage) fails (logging-log4j2)

zeimao77 opened a new issue, #2434:
URL: https://github.com/apache/logging-log4j2/issues/2434

   - The log plugin was not loaded correctly after packaging with jlink  
   [Plug_code](https://github.com/zeimao77/zeimao77-productivity/blob/main/zeimao77-productivity/src/main/java/top/zeimao77/product/log4j2/ConfigurationFacotry77.java)  
   [Add Plug](https://github.com/zeimao77/zeimao77-productivity/blob/main/zeimao77-productivity/src/main/java/top/zeimao77/product/main/BaseMain.java)#initLoggerConfig();
   
   
   ```bash
   [abc@zeimao77-pc]/mnt/e/helloworld% java --module-path libs/test.product.jar\
   :libs/jackson-annotations-2.14.2.jar\
   :libs/jackson-core-2.14.2.jar\
   :libs/jackson-databind-2.14.2.jar\
   :libs/jackson-datatype-jsr310-2.14.2.jar\
   :libs/log4j-api-2.23.1.jar\
   :libs/log4j-core-2.23.1.jar\
   :libs/log4j-slf4j2-impl-2.23.1.jar\
   :libs/slf4j-api-2.0.6.jar\
   :libs/zeimao77-productivity-2.2.2.jar -m test.product/com.zeimao77.Main
   initLoggerConfig__top.zeimao77.product.log4j2
   ConfigurationFacotry77()....
   getSupportedTypes____77.conf
   getSupportedTypes____77.conf
   getSupportedTypes____77.conf
   getSupportedTypes____77.conf
   getSupportedTypes____77.conf
   getConfiguration__jar:file:///mnt/e/helloworld/libs/zeimao77-productivity-2.2.2.jar!/log4j2.77.conf
   ----------------------------
   java.xml,jdk.random,java.management.rmi,org.apache.logging.log4j.slf4j2.impl,jdk.jfr,org.slf4j,jdk.internal.opt,jdk.compiler,org.apache.logging.log4j.core,java.xml.crypto,java.datatransfer,java.desktop,jdk.internal.ed,jdk.editpad,java.scripting,java.logging,jdk.zipfs,java.compiler,jdk.charsets,com.fasterxml.jackson.core,jdk.jartool,jdk.security.jgss,jdk.jdwp.agent,jdk.management,java.management,jdk.crypto.ec,jdk.naming.rmi,jdk.naming.dns,jdk.management.jfr,java.rmi,jdk.jdeps,jdk.jdi,org.apache.logging.log4j,jdk.internal.le,java.base,java.security.sasl,jdk.internal.jvmstat,jdk.jstatd,jdk.unsupported.desktop,java.naming,jdk.jshell,test.product,jdk.crypto.cryptoki,com.fasterxml.jackson.datatype.jsr310,com.fasterxml.jackson.annotation,jdk.security.auth,java.smartcardio,jdk.jpackage,zeimao77.productivity,java.security.jgss,jdk.localedata,java.prefs,jdk.javadoc,jdk.attach,com.fasterxml.jackson.databind,jdk.jlink
   2024-04-01 10:26:28,694 [main] INFO  (BaseMain:132):            /\_/\
   2024-04-01 10:26:28,703 [main] INFO  (BaseMain:133):      _____/ o o \
   2024-04-01 10:26:28,704 [main] INFO  (BaseMain:134):    /~_____  =-= /
   2024-04-01 10:26:28,704 [main] INFO  (BaseMain:135):   (__zm77__)_m_m)
   2024-04-01 10:26:28,713 [main] INFO  (BaseMain:137):   app-version:0.0.1
   2024-04-01 10:26:28,716 [main] DEBUG (BaseMain:16): 262861003899797506
   2024-04-01 10:26:28,716 [main] INFO  (BaseMain:17): 262861003903991811
   2024-04-01 10:26:28,716 [main] WARN  (BaseMain:18): 262861003903991812
   2024-04-01 10:26:28,717 [main] ERROR (BaseMain:19): 262861003903991813
   2024-04-01 10:26:28,717 [main] INFO  (BaseMain:20): 18e977ac2ed
   
   [abc@zeimao77-pc]/mnt/e/helloworld% jlink --module-path libs/test.product.jar\
   :libs/jackson-annotations-2.14.2.jar\
   :libs/jackson-core-2.14.2.jar\
   :libs/jackson-databind-2.14.2.jar\
   :libs/jackson-datatype-jsr310-2.14.2.jar\
   :libs/log4j-api-2.23.1.jar\
   :libs/log4j-core-2.23.1.jar\
   :libs/log4j-slf4j2-impl-2.23.1.jar\
   :libs/slf4j-api-2.0.6.jar\
   :libs/zeimao77-productivity-2.2.2.jar\
    --add-modules java.security.jgss,jdk.localedata,java.datatransfer,jdk.crypto.ec,test.product,jdk.naming.rmi,java.logging,jdk.jpackage,java.compiler,jdk.jshell,jdk.unsupported.desktop,java.xml,jdk.security.auth,com.fasterxml.jackson.core,jdk.internal.ed,jdk.jlink,java.smartcardio,java.rmi,java.security.sasl,jdk.jartool,jdk.internal.le,jdk.attach,org.apache.logging.log4j.slf4j2.impl,java.naming,org.apache.logging.log4j.core,jdk.compiler,jdk.management.jfr,jdk.management,jdk.jdwp.agent,org.apache.logging.log4j,java.management.rmi,java.desktop,jdk.internal.opt,java.management,zeimao77.productivity,jdk.editpad,com.fasterxml.jackson.databind,jdk.zipfs,jdk.jstatd,org.slf4j,jdk.jfr,java.prefs,jdk.internal.jvmstat,java.xml.crypto,java.base,jdk.charsets,com.fasterxml.jackson.datatype.jsr310,jdk.security.jgss,jdk.jdeps,jdk.jdi,jdk.javadoc,jdk.random,jdk.naming.dns,java.scripting,jdk.crypto.cryptoki,com.fasterxml.jackson.annotation --output app
    
   [abc@zeimao77-pc]/mnt/e/helloworld%  app/bin/java --module test.product
   initLoggerConfig__top.zeimao77.product.log4j2
   ----------------------------
   java.logging,jdk.jdeps,java.base,jdk.javadoc,jdk.internal.jvmstat,java.desktop,jdk.management.jfr,jdk.zipfs,jdk.jdwp.agent,zeimao77.productivity,jdk.internal.ed,jdk.unsupported.desktop,java.xml,jdk.jlink,jdk.crypto.ec,com.fasterxml.jackson.annotation,java.management.rmi,java.prefs,java.xml.crypto,jdk.editpad,org.slf4j,jdk.localedata,jdk.jartool,java.naming,jdk.jpackage,jdk.attach,test.product,com.fasterxml.jackson.datatype.jsr310,jdk.internal.le,jdk.management,java.compiler,java.management,org.apache.logging.log4j,org.apache.logging.log4j.slf4j2.impl,java.datatransfer,java.security.sasl,java.smartcardio,jdk.security.auth,com.fasterxml.jackson.databind,java.scripting,jdk.jshell,jdk.jdi,jdk.jstatd,jdk.naming.rmi,jdk.internal.opt,jdk.compiler,com.fasterxml.jackson.core,org.apache.logging.log4j.core,jdk.jfr,jdk.naming.dns,jdk.crypto.cryptoki,java.security.jgss,jdk.charsets,jdk.security.jgss,jdk.random,java.rmi
   10:26:54.317 [main] ERROR top.zeimao77.product.main.BaseMain - 262861111089430533
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] After modularization of Log4j2, loading the plugin (PluginManager. addPackage) fails (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #2434:
URL: https://github.com/apache/logging-log4j2/issues/2434#issuecomment-2037064399

   @zeimao77,
   
   The classpath scanning functionality provided by the [`PluginManager#addPackage`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/config/plugins/util/PluginManager#addPackage(java.lang.String)) method has been deprecated in [`LOG4J2-3644`](https://issues.apache.org/jira/browse/LOG4J2-3644) and you should not use it. Instead of using the method, you should compile your code with the:
   
   ```
   org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
   ```
   
   which is available since Log4j 2.0. The processor will generate the necessary `META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat` descriptor that replaces classpath scanning.
   
   I have update our [`log4j-samples-jlink`](https://github.com/apache/logging-log4j-samples/tree/main/log4j-samples-jlink) example to support your use case of custom configuration factory. You can test it by checking out the repository and running:
   
   ```shell
   ./mvnw clean install -pl log4j-samples-jlink -am
   log4j-samples-jlink/target/maven-jlink/default/bin/java\
     -Dlog4j2.configurationFile=classpath:log4j2.custom\
     --add-modules org.apache.logging.log4j.samples.configuration\
     -m org.apache.logging.log4j.samples.jlink/org.apache.logging.log4j.samples.jlink.Main
   ```
   
   inside of it.
   
   Hope this helps you with your problem. If it doesn't, can you provide a minimal reproducible example?
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] After modularization of Log4j2, loading the plugin (PluginManager. addPackage) fails (logging-log4j2)

Posted by "zeimao77 (via GitHub)" <gi...@apache.org>.
zeimao77 commented on issue #2434:
URL: https://github.com/apache/logging-log4j2/issues/2434#issuecomment-2044291392

   You were right and successfully solved my problem;
   The current method of parsing plugins at compile time is much better than the PluginManager method;
   And it avoids the need to execute PluginManager before all methods are executed AddPackage;


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] After modularization of Log4j2, loading the plugin (PluginManager. addPackage) fails (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #2434: After modularization of Log4j2, loading the plugin (PluginManager. addPackage) fails
URL: https://github.com/apache/logging-log4j2/issues/2434


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org