Logging in OSGI Enterprise Applications, Part 4

Part 4 will demonstrate how to start the logging – framework and all the bridges inside an OSGI Enterprise Application.

To remember: At the end of the last (third) part of my blog – series “Logging in OSGI Enterprise Applications” we were able to log all events from „classic“ log-frameworks, OSGI LogServices, BundleEvents and FrameworkEvents using a SLF4J Log – implementation (LOGBack):

If we want to use it all inside a complex OSGI Enterprise Application its important to start the bundles using the right start-level. We also have to decide which bundles can be auto-started from the framework and which not.

As an example I’ll use again my OSGI – Equinox – Riena – EasyBeans – Hibernate – Server. I’ll talk in detail about this server later in one of the follow-ups.

From OSGI Launch Configuration:

Default Start – Level is set to 3.

Our osgi-over-slf4j – Bundle must be started before (Start-Level = 2) and the EasyBeans – Agent – Bundle later (Start-Level = 4)

We also have to watch that some bundles cannot be started with Auto-Start = true ! These bundles will be started under control from EasyBeans Agent bundle.

All bundles with Auto-Start = true will be started then from the Framework. This includes all Eclipse Riena bundles. Riena uses LOG4J – so the LOG4J – bridge will be started. Riena also uses Equinox – Extended – OSGI – Log – Services.

The org.ekkehard.server bundle tracks OSGI Managed Services and recognizes, when all required services are configured from EasyBeans and Hibernate and ready-to-go. Then org.ekkehard.server registers Services as Remote Services for Eclipse Riena.

Remark: This is only a small part of all the activities and tasks happening while starting the server. More about 4. and 5. later in another blog series. Lets first finishing the logging.

No black holes ?

If we did it all well, then our SLF4J – Implementation LOGBack should start so early that we get all log – events and nothing is lost in space.

To test this we configure our logback-test.xml as follows: set Root Level to DEBUG, output to Console, swich DEBUG – Mode of the configuration itself on and start the server.

You should get a log like this:

Line 1: equinox – osgi – Console

Line 2 – 7: Debug-output from LOGBack configuration

Line 8 – 9: Logging-output from osgi-over-slf4j – bundle

There’s no other logging-output on the console before starting SLF4J / LOGBack 🙂

The next blog will look at the configuration of LOGBack and some special Fragment – Bundles for configuration and also extending the LOGBack – implementation.