You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Philipp Haussleiter edited this page Nov 25, 2015
·
1 revision
Logging
We are using SLF4J for logging as it promises to integrate different logging approaches well.
See http://ekkes-corner.blogspot.com/2008/10/logging-in-osgi-enterprise-applications_31.html
The pattern for logging should be as follows.
In an Activator:
private static Logger LOG = LoggerFactory.getLogger(Activator.class);
public static final String ID = "symbolic_bundle_name";
public static final Marker BUNDLE_MARKER = createBundleMarker();
private static Marker createBundleMarker() {
Marker bundleMarker = MarkerFactory.getMarker(ID);
bundleMarker.add(MarkerFactory.getMarker("IS_MARKER"));
return bundleMarker;
}
In each class of the bundle we declare:
import static MyActivator.BUNDLE_MARKER;
private static final Logger LOG = LoggerFactory.getLogger(Foo.class);
To actually log with the bundle marker, we write log statements like this:
if (LOG.isInfoEnabled()) LOG.info(BUNDLE_MARKER, "Starting BundleBee carrier...");
Currently, logging is configured with trunk/src/main/equinox/plugins/logback.xml (or plugins/logback.xml in the distr. package).
Configuring logging with a fragment bundle failed due to classloading difficulties (one framework extensions does not seem to be able to see another). See notes in the top part of the class BundleBeeClassLoadingHook.
TODO: Add BundleMarkerConverter Fragment, so that we actually benefit from the marker!