Multiple SLF4J bindings in JBOSS casued ERROR
Our application have several EARs deployed to a single JBOSS-AS.
Every EAR uses SLF4J for logging and it is available in WAR's lib. We also have a case where we will deploy the EARs separately too.
Following is the deployment ERRORs we got for a single EAR. Similar kind of ERRORs we are getting for each of the EARs.
2011-07-07 23:27:52,794 ERROR [STDERR] (main) SLF4J: Class path contains multiple SLF4J bindings.
2011-07-07 23:27:52,794 ERROR [STDERR] (main) SLF4J: Found binding in [vfszip:/jboss-as/common/lib/li开发者_高级运维b/slf4j-jboss-logging.jar/org/slf4j/impl/StaticLoggerBinder.class]
2011-07-07 23:27:52,794 ERROR [STDERR] (main) SLF4J: Found binding in [vfszip:/Product_Ear.ear/Product_War.war/WEB-INF/lib/slf4j-jcl-1.5.8.jar/org/slf4j/impl/StaticLoggerBinder.class]
2011-07-07 23:27:52,794 ERROR [STDERR] (main) SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
This error is because we have multiple bindings of SLF4j as per the explanation URL.
Questions :
Shouldn't that be a WARNING instead of an ERROR?
Is there any way how to run it without errors and without removing slf4j-jcl-1.5.8.jar from WARs?
SideNote : Even if we got errors for most of the EARs, there are no other problems because of this. Every indented functionality are working fine.
This behaviour of slf4j is by design. If you do not like it, you must raise a bug report on the slf4j site.
The problem is that JBoss provide a slf4j binding in its default classloader, and you bring your own. I am not familiar enough with JBoss to say if the slf4j jar in common/lib is available by default, or if you put it there, but at that location you probably cannot disable it. You may want to raise a bug report on the jboss site.
The problem stems from I do not believe it has been explicitly said in the servlet spec what the web container classloader should provide and what it should not. Hence there will be deployment issues.
The only cure is to remove your own slf4j binding and log to the jboss loggers.
But note, it will be most cross platform for you if you let the web container do the logging, as you are not guaranteed to have access to the file system by the spec.
精彩评论