[GRADLE-897] Gradle's SLF4J bindings are visible to webapp run with the Jetty plugin Created: 08/Apr/10 Updated: 22/Nov/16 Resolved: 22/Nov/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Jeppe Nejsum Madsen | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 21 |
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. This may cause unpredictable logging since it is not clear which logging backend is being used.... |
Comments |
Comment by Wolfgang Schell [ 26/May/11 ] |
I see the same behavior. |
Comment by Thomas Baur [ 13/Jul/11 ] |
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 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. |
Comment by island chen [ 08/Sep/11 ] |
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. |
Comment by Jeremy Judeaux [ 29/Dec/11 ] |
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 |
Comment by Christian Lipp [ 21/Feb/13 ] |
I am not sure if this belongs to this issue, but I would like to mention it (just to make sure): SLF4J: Class path contains multiple SLF4J bindings. A similar problem (or the same) occurs when using slf4j for a project with a Gradle build and using the STS Gradle plugin. |
Comment by chen [ 07/Apr/13 ] |
I see the same behaviour... +1024,i wonder how can i solve this problem? |
Comment by Tom Dunstan [ 21/Aug/13 ] |
+1 I just hit this. If I leave logback out of the webapp, it complains with: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". but if I add logback-classic in as a runtime dependency, I get: SLF4J: Class path contains multiple SLF4J bindings. So it seems that there's no way I can get SLF4J to be quiet. |
Comment by Matt Hauck [ 23/Aug/13 ] |
I think the only way to get around this is to have the jetty/tomcat plugins fork so that the webapp runs in a separate jvm that does not contain gradle's own classpath. |
Comment by Tom Dunstan [ 24/Aug/13 ] |
Well, without knowing much about Gradle's internals, there are a couple of potential solutions that servlet engines and app servers have used over the years:
Maybe logging needs to be in the root classloader for error reporting problems, though... |
Comment by Matt Hauck [ 26/Aug/13 ] |
In case it benefits anyone, I made a simple tomcat plugin that forks into a new process to avoid issues like this. Something similar could easily be done with jetty. https://gist.github.com/matthauck/6338633 |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Jochen Kemnade [ 16/Nov/16 ] |
Since the jetty plugin is deprecated, I guess this is a WONTFIX. |
Comment by Benjamin Muschko [ 22/Nov/16 ] |
The Jetty plugin has been deprecated and will be removed with Gradle 4.0. Consequently, we are not planning to fix this issue anymore. |