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

[OSGi] Provide Appender-Bundles

    XMLWordPrintableJSON

    Details

      Description

      Instead of deploying all appenders in the core fragment, it would be much better if the customer can choose which appender he wants to provide. (I want a lightweight version without database and http stuff. I do not want to install libraries, which I do not need. All the (transitiv) log4j2-dependencies together are much bigger than my own application.)
      It's easy to hive the appender off in a separate bundle fragment. The host bundle is the API bundle. The Plugin Manager (core fragment) finds the deployed appenders in the classpath of the host bundle. The PluginManager should parse the class path in a separate thread (Startup-Hook) and only once at the start of the host bundle, but not for each call (when a consumer bundle aquires a logger). Make package-imports optional (<Import-Package>*;resolution:=optional</Import-Package>)!!!!

      This reduces the number of dependencies and reduces the startup time of the whole system.

      One possible solution for the Plugin Manager is to use the reflections plugin during the maven build process. This plugin lists all classes of a project within a xml file. This file can be marked as a bundle resource and is stored within the appender bundle fragment. The idea is that each appender fragment has its own class list. Because the bundle host (log4j2 core) sees all resources of its fragments it can load these class lists at runtime. Thus, the Plugin Manager gets only those appenders that are installed within deployed bundle fragements. The class list is created during the build process, the plugin manager must not parse the classpath at runtime. Log4j2 uses a xml parser by default. An additional new dependency to a xml-parser library is not required.

      <plugin>
      <groupId>org.reflections</groupId>
      <artifactId>reflections-maven</artifactId>
      <version>0.9.8</version>
      <executions>
      <execution>
      <goals>
      <goal>reflections</goal>
      </goals>
      <phase>process-classes</phase>
      </execution>
      </executions>
      <configuration>
      <destinations>${project.basedir}/META-INF/reflections/${project.artifactId}-reflections.xml</destinations>
      </configuration>
      </plugin>

        Attachments

        1. Unbenannt.jpg
          1.21 MB
          Roland Weiglhofer

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rol Roland Weiglhofer
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: