In an Eclipse RCP application, how can I automatically log each plug-in as it is being started?
I know about these, but am looking for something more akin to Java's -verbose:class
:
This feels like an option that should already exist. Seems like there should be an option to automatically log bundle-state changes for plug-ins. But I haven't found anything after a quick search online and in books. Am I missing something obvious?
Bundle state changes are already logged by OSGi to the Log Service. Please refer to chapter 101 of the OSGi Compendium specification.
If you want to log bundle start events using some specific mechanism other than the standard Log Service, then you can write a BundleListener
. The trick is to get your listener registered early enough so you catch all the other bundles being started (obviously if the bundle containing the listener is started last then it will not be able to see these events).
If you are in control of the top-level application then you should be able to register the listener from the OSGi launcher, i.e. using the BundleContext
of the system bundle itself. But the launcher is usually in control of starting bundles anyway, meaning that the time to log the start of a bundle is when your code calls start()
on each of them! It all depends on how your application is structured.