Gradle

Gradle's SLF4J bindings are visible to webapp run with the Jetty plugin

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 0.9
  • Fix Version/s: someday
  • Component/s: plugins
  • Labels:
    None
  • Environment:
    OSX, gradle 0.9rc1

Description

Using jettyRun with a webapp that contains SLF4J bindings causes warnings to be printed since Gradle's bindings are also visible to the webapp:

:jettyRunSLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/local/share/java/gradle/lib/logback-classic-0.9.18.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jeppe/.gradle/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

This may cause unpredictable logging since it is not clear which logging backend is being used....

Activity

Hide
Wolfgang Schell added a comment -

I see the same behavior.

Show
Wolfgang Schell added a comment - I see the same behavior.
Hide
Thomas Baur added a comment -

This causes some headaches if the version of slf4j that is requested in the project WAR itself is different. A wrong version of the static facade may be called:

java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)

This is due to a mix of classes from slf4j 1.6.1 (used in the project) and 1.4.3 (probably), used internally in logback-classic-0.9.24.jar, which resides in gradle/lib.

Show
Thomas Baur added a comment - This causes some headaches if the version of slf4j that is requested in the project WAR itself is different. A wrong version of the static facade may be called: java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) This is due to a mix of classes from slf4j 1.6.1 (used in the project) and 1.4.3 (probably), used internally in logback-classic-0.9.24.jar, which resides in gradle/lib.
Hide
island chen added a comment -

I see the same behavior too.

According to http://www.slf4j.org/codes.html#multiple_bindings, that means "SLF4J will still bind with the first framework it finds on the class path" – which in gradle will always be StaticLoggerBinder, and this is definitely what we want.

Show
island chen added a comment - I see the same behavior too. According to http://www.slf4j.org/codes.html#multiple_bindings, that means "SLF4J will still bind with the first framework it finds on the class path" – which in gradle will always be StaticLoggerBinder, and this is definitely what we want.
Hide
Jeremy Judeaux added a comment -

I see the same behaviour, and the face that it uses StaticLoggerBinder is definitely not what I want. I'm expecting that slf4j uses the binding to LOG4J, not the one to Logback.

This bug seems to be the consequence of this Jetty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=297421
Upgrading to Jetty 7 should fix it, but I don't know how to do that.

Show
Jeremy Judeaux added a comment - I see the same behaviour, and the face that it uses StaticLoggerBinder is definitely not what I want. I'm expecting that slf4j uses the binding to LOG4J, not the one to Logback. This bug seems to be the consequence of this Jetty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=297421 Upgrading to Jetty 7 should fix it, but I don't know how to do that.

People

Vote (5)
Watch (3)

Dates

  • Created:
    Updated: