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

Log4j2 failed to load custom plugin

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.17.1
    • None
    • Plugins
    • None

    Description

      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            xzhao1 XIAOMING ZHAO
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: