You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "XIAOMING ZHAO (Jira)" <ji...@apache.org> on 2022/05/26 14:57:00 UTC

[jira] [Created] (LOG4J2-3519) Log4j2 failed to load custom plugin

XIAOMING ZHAO created LOG4J2-3519:
-------------------------------------

             Summary: 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


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)