views:

327

answers:

1

I'm building a small Java app and hoping to use logback for logging.

My app has a dependency on an older project that does its logging via

org.apache.commons | com.springsource.org.apache.commons.logging | 1.1.1

...so my plan was to use

org.slf4j | jcl-over-slf4j | 1.5.6

...to redirect the JCL logging to

org.slf4j | slf4j-api | 1.6.0

...and ultimately to

ch.qos.logback | logback-classic | 0.9.22
ch.qos.logback | logback-core | 0.9.22

so my app can log through logback via its slf4j API while the old library code can log into the same location via the redirection.

Alas, this results in

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at   org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:141)

I've tried higher and lower verision numbers on some of these jars and also digging through API documentation and such... but I'm unable to find and solve the problem.

Help, please?

Although logback is considered the "strategic" logging framework, I have some leeway in which logging mechanism I ultimately use. I'd hope to use either logback or log4j, though, and I definitely want to merge the old project's logging into whatever the "new" logging framework ends up being, via a common configuration.

+2  A: 

You are mixing the 1.5.6 version of the jcl bridge with the 1.6.0 version of the slf4j-api; this won't work because of a few changes in 1.6.0. Use the same versions for both, i.e. 1.6.1 (the latest). I use the jcl-over-slf4j bridge all the time and it works fine.

Holger Hoffstätte
That worked right away, of course; thank you very much! I hadn't used 1.6.1 of those jars because they didn't appear to be available. I'm highly annoyed at m2eclipse, which purports to show me all available versions yet mysteriously drops a significant number of them.
Carl Smotricz
Just for interest of anyone else following: I ended up with a red arrow in the dependency graph because even the latest logback-core insists on slf4j-1.6.0. It took some more diddling around with versions until all the red arrows disappeared, but now it's both working and all blue arrows.
Carl Smotricz