Package de.mnl.osgi.osgi2jul

A bundle that forwards events from the OSGi logging service to java.util.logging (JUL).

GitHub issues Maven Central


The bundle is deployed as any other OSGi bundle

Forwarding functionality

The bundle installs a LogListener on every discovered LogService. The listener forwards each received LogEntry to the configured JUL Handlers.

The mapping of JUL LogEntry properties to OSGi LogRecord properties should be obvious with two exceptions:

  • LogLevel.AUDIT: is mapped to a JUL Level with integer value MAX_VALUE .
  • Bundle: as this information has no direct representation in the JUL LogRecord, it can be inserted into the log message (see below).
If a format property is set for a handler, the log message is post-processed with a MessageFormat instance created from the specified format. The formatter is invoked with the parameters "original message", "bundle symbolic name", "bundle name", "bundle version", "thread info".

In order to e.g. add the bundle name to the message, the format pattern "{0} [{2}]" could be used.

Bundle properties

The following bundle properties configure the described behavior.
Bundle parameters
de.mnl.osgi.osgi2jul.handlers A comma separated list of Handler classes. If the handlers are to be taken from a bundle, use "<bundle symbolic name>:<class name>". For further configuration, an id can be appended as "[<id>]". ConsoleHandler
de.mnl.osgi.osgi2jul.handler.<id>.format The format used to post-process messages before passing them to the handler (see above). No post-processing
de.mnl.osgi.osgi2jul.handler.<id>.level Used to set the level property of the handler. None