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

XIAOMING ZHAO commented on LOG4J2-3519:
---------------------------------------

from the log before the " showing stack trace to locate invoker".  like the 
following logs, it did scanning bundles for plugins, but don't know how it 
specify some bundles, but not include my bundle which include the custom 
plugin,  how log4j2 know which bundles should be scanned or how to define to 
scan a bundle?

    920 TRACE StatusLogger Scanning bundle 
[com.mycompany.as.service.bundleinstaller.impl, id=%d] for plugins.
    921 DEBUG StatusLogger Took 0.002526 seconds to load 0 plugins from 
com.mycompany.as.service.bundleinstaller.impl [1]
    922 TRACE StatusLogger Scanning bundle [com.mycompany.tpapps.sps-common, 
id=%d] for plugins.
    923 DEBUG StatusLogger Took 0.000103 seconds to load 0 plugins from 
com.mycompany.tpapps.sps-common [54]
    924 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.api, 
id=%d] for plugins.
    925 DEBUG StatusLogger Took 0.000028 seconds to load 0 plugins from 
org.apache.logging.log4j.api [224]
    926 TRACE StatusLogger Scanning bundle 
[org.apache.aries.spifly.dynamic.bundle, id=%d] for plugins.
    927 DEBUG StatusLogger Took 0.000043 seconds to load 0 plugins from 
org.apache.aries.spifly.dynamic.bundle [369]
    928 DEBUG StatusLogger Loaded Provider Provider[priority=10, 
class=org.apache.logging.log4j.core.impl.Log4jContextFactory, 
classLoader=null(not reachable)]
    929 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.core, 
id=%d] for plugins.
    930 DEBUG StatusLogger Took 0.068493 seconds to load 222 plugins from 
org.apache.logging.log4j.core [327]
    931 DEBUG StatusLogger Loaded Provider Provider[priority=10, 
class=org.apache.logging.log4j.core.impl.Log4jContextFactory, 
classLoader=null(not reachable)]
    932 TRACE StatusLogger Scanning bundle [org.apache.cxf.cxf-core, id=%d] for 
plugins.

 

 

> Log4j2 failed to load custom plugin 
> ------------------------------------
>
>                 Key: LOG4J2-3519
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3519
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Plugins
>    Affects Versions: 2.17.1
>            Reporter: XIAOMING ZHAO
>            Priority: Major
>
> We got some issue to load the custom plugin.
> we add annotation Plugin like the following:
> @Plugin(name = "UnifiedLoggingFormat", category = Node.CATEGORY,
>         elementType = Layout.ELEMENT_TYPE, printObject = true)
> public class UnifiedLoggingFormat extends AbstractStringLayout
> then add the annotationProcessor in build.gradle
>    annotationProcessor( 'org.apache.logging.log4j:log4j-core:2.17.1')
>  
> after the build, we can see the  
> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat in 
> the class jar file.
> > jar tvf *appender*.jar
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/
>   1077 Tue May 24 14:18:40 EDT 2022 META-INF/MANIFEST.MF
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/org/
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/log4j/
>      0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/log4j/core/
>      0 Tue May 24 14:18:40 EDT 2022 
> META-INF/org/apache/logging/log4j/core/config/
>      0 Tue May 24 14:18:40 EDT 2022 
> META-INF/org/apache/logging/log4j/core/config/plugins/
>    236 Tue May 24 14:18:40 EDT 2022 
> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
>  
> then in log42j.xml, we added the package of this custom plugin class.
> <Configuration status="trace" monitorInterval="30" 
> packages="com.server.logging.log4jappenders, com.common.utils">
>  
> but we still got the problem 
> FelixDispatchQueue DEBUG Took 0.003516 seconds to load 0 plugins from package 
> com.server.logging.log4jappenders
> FelixDispatchQueue DEBUG Took 0.000117 seconds to load 0 plugins from package 
> com.common.utils
>  
> Would you please help out?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to