Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » OSGi + Logback + slf4j - Eclipse Run Configuration
OSGi + Logback + slf4j - Eclipse Run Configuration [message #987726] Tue, 27 November 2012 18:36 Go to next message
Tobias P. is currently offline Tobias P.
Messages: 43
Registered: April 2012
Member
Hello,

here is my configuration:

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

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Createcommand
Bundle-SymbolicName: de.hswt.oms.ws.wsr.createcommand
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: de.hswt.oms.ws.command.wsr,
de.hswt.oms.ws.ds.core.data.impl,
org.slf4j
Service-Component: OSGI-INF/component.xml
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
Re: OSGi + Logback + slf4j - Eclipse Run Configuration [message #987787 is a reply to message #987726] Wed, 28 November 2012 07:48 Go to previous message
Christoph Keimel is currently offline Christoph Keimel
Messages: 371
Registered: December 2010
Location: Germany
Senior Member
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:
slf4j-api-1.6.6.jar
logback-classic-1.0.6.jar
logback-core-1.0.6.jar

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.

Greetings
Christoph
Previous Topic:Jetty Hello World
Next Topic:Simple run fails (eclipse helios sr1 jee)
Goto Forum:
  


Current Time: Sat Oct 25 07:47:13 GMT 2014

Powered by FUDForum. Page generated in 0.01519 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software