Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You need three OSGi bundles added to your environment. Here they are as Maven POM dependencies. pax-logging-api is the bundle that provides the various logging APIs, while pax-logging-service provides the implementation of the logging service that delivers the log messages via log4j. pax-logging uses Configuration Admin to get log4j configuration, so you need that, too.

  1. Dependencies you need:

    Code Block
    languagexml
    titleDependencies
     <dependency>
        <groupId>org.ops4j.pax.logging</groupId>
        <artifactId>pax-logging-api</artifactId>
        <version>1.8.3</version>
     </dependency>
     <dependency>
        <groupId>org.ops4j.pax.logging</groupId>
        <artifactId>pax-logging-service</artifactId>
        <version>1.8.3</version>
        <!-- Note that this bundle declares a dependency on log4j -->
     </dependency>
     <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.configadmin</artifactId>
        <version>1.8.8</version>
     </dependency>
  2. You need to configure the disposition of the log messages. Pax-logging has a default log4j configuration, and you can configure the top-level severity with a system property. You can configure the details with the OSGi Configuration Admin service.  See  Configuration (previous) for details. If you need to use appender classes (or formatter classes) that are not part of the standard Log4J bundle, you need to use a fragment bundle to make them available to pax-logging-service. Several blog posts (e.g. This one from Achim Nierbeck) have this information.

...