We are developing an OSGi application and want to include logging. I decided to use slf4j + logback.
We are using Eclipse as an IDE and Tycho to benefit from the Eclipse IDE like Manifest Editor and so on.
So i have tried the following:
Created a new plugin with the following Manifest.mf
Now when i move to Run -> Run Configurations -> OSGi Framework and select my Bundle and clicl "Add Required plugins" more then 100 Bundles will be selected and i get a lot of errors and exceptions.
So i came up with a new plugin from existing Jars which includes the following three jars: logback-classic-1.0.7 logback-core-1.0.7 com.springsource.slf4j.api-1.6.1 (I dont believe this is a good idea, but hey...)
If i create a new run configuration manually (not clicking "add required bundles" it works as expected but as far as i click "add required bundles" i come back to the more then 100 Bundles with a lot of errors (some jetty stuff for example...)
So my Question is: How can i enable logback and slf4j in my OSGi application and use it within eclipse and configure it properly???
If you need more information please feel free to ask
I have had the same problem. The cause is probably that there is already a plugin in the platform which exposes the org.slf4j api. This plugin will be linked with others from the platform, so they get pulled in on "Add Required". You can have a look at your current target platform with the view "Plug-ins" and also "Target Platform State".
I solved it by creating my own Target (File > New > Target Definition) which includes only the plugins I realy want to work with including my own slf4j jars. You can use the slf4j and logback jars directly, because they are already configured for OSGi. So my target includes among others:
Another possibility is to disable all the unwanted plugins by editing the "Running Platform" in Preferences > Plug-in Development > Target Platform. Imho it is easier to maintain your own target definition though.