Home » Eclipse Projects » e(fx)clipse » Trouble when trying to use log4j(Error "SLF4J: Class path contains multiple SLF4J bindings")
| | |
Re: Trouble when trying to use log4j [message #1439534 is a reply to message #1436870] |
Tue, 07 October 2014 08:50 |
Christoph Keimel Messages: 482 Registered: December 2010 Location: Germany |
Senior Member |
|
|
SLF4j throws this error if more than one implemenation of its API is found on the classpath. But anyway ... if I understand you correctly, you want to use LOG4j (and not SLF4J). Is that correct? If so, there should not be any SLF4J error.
I tried to reproduce the issue, but failed. I did this:
- Create a new e4-fx application with the wizard
- add org.eclipse.fx.core.log4j to the feature.xml
- add plugin publishing log4j packages to feature.xml
- add fragment with log4j configuration to feature.xml
I then injected the Logger into a lifecycle handler
public class LifeCycleManager {
@PostContextCreate
Boolean postContextCreate(@Log Logger logger) {
logger.debug("DEBUG");
logger.info("DEBUG");
logger.warning("DEBUG");
logger.error("ERROR", new Exception("Just a exception"));
return false;
}
}
The loggging works for me. I also started the application using the osgi console (-console) and verified with ss -> there is no slf4j bundle beeing started.
[Updated on: Tue, 07 October 2014 08:59] Report message to a moderator
|
|
|
Re: Trouble when trying to use log4j [message #1439539 is a reply to message #1436252] |
Tue, 07 October 2014 08:58 |
Christoph Keimel Messages: 482 Registered: December 2010 Location: Germany |
Senior Member |
|
|
Hi Tom,
if you look at the included bundles with ss, do you see more than one implementation of the slf4j API on the list? Maybe two of logback, slf4j.log4j, slf4j.simple, slf4j.nop, etc ...
I have seen this issue before, when I used "Add required bundles". Because slf4j.log4j is a fragment it gets added as soon as slf4j.api is around.
Greetings
Christoph
Thomas Schindl wrote on Thu, 02 October 2014 18:18I think slf4j is causing this troubles - I've seen this problem myself
just yesterday myself when I dropped slf4j into my runtime config. So
there's something heavily crazy going on with slf4j. Need to debug
please file a bug report!
Tom
On 02.10.14 07:38, Thomas Elskens wrote:
> Hello,
>
> I tried the recipe
> http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an
> instance of the default java.util.Logger. This worked fine.
> However, when adding the plugin org.eclipse.fx.core.log4j in order to
> use the log4j implementation, I get the following error when the
> logger.info(...) is called :
> Quote:
>> SLF4J: Class path contains multiple SLF4J bindings.
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404:2/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
>> explanation.
>> SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
>> Exception in thread "JavaFX Application Thread"
>> java.lang.StackOverflowError
>> at java.util.Hashtable.containsKey(Unknown Source)
>> at
>> org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
>> at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
>> at
>> org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>> at org.apache.log4j.Category.<init>(Category.java:56)
>> at org.apache.log4j.Logger.<init>(Logger.java:36)
>
>
> I've found only few references of this error on the net (e.g.
> http://www.slf4j.org/codes.html#multiple_bindings,
> http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings
> and
> http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin,
> but none of the proposed solutions seem applicable : there's no
> dependency defined in the POM, there is no conflict on the classpath (as
> the bindings stem apparently twice from the same plugin) .
> Any idea of how to solve this ... ? Perhaps it's more of a question
> regarding log4j ... ?
>
> Thomas
>
|
|
|
Re: Trouble when trying to use log4j [message #1439557 is a reply to message #1439539] |
Tue, 07 October 2014 09:25 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
I did something nasty because I copied stuff (jars, ...) together to
assemble a bundle with its prereqs so the error is most likely really bogus.
Tom
On 07.10.14 10:58, Christoph Keimel wrote:
> Hi Tom,
>
> if you look at the included bundles with ss, do you see more than one
> implementation of the slf4j API on the list? Maybe two of logback,
> slf4j.log4j, slf4j.simple, slf4j.nop, etc ...
>
> I have seen this issue before, when I used "Add required bundles".
> Because slf4j.log4j is a fragment it gets added as soon as slf4j.api is
> around.
>
> Greetings
> Christoph
>
> Thomas Schindl wrote on Thu, 02 October 2014 18:18
>> I think slf4j is causing this troubles - I've seen this problem myself
>> just yesterday myself when I dropped slf4j into my runtime config. So
>> there's something heavily crazy going on with slf4j. Need to debug
>> please file a bug report!
>>
>> Tom
>>
>> On 02.10.14 07:38, Thomas Elskens wrote:
>> > Hello,
>> > > I tried the recipe
>> > http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an
>> > instance of the default java.util.Logger. This worked fine.
>> > However, when adding the plugin org.eclipse.fx.core.log4j in order to
>> > use the log4j implementation, I get the following error when the
>> > logger.info(...) is called :
>> > Quote:
>> >> SLF4J: Class path contains multiple SLF4J bindings.
>> >> SLF4J: Found binding in
>> >>
>> [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> >>
>> >> SLF4J: Found binding in
>> >>
>> [bundleresource://176.fwk1616974404:2/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> >>
>> >> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
>> >> explanation.
>> >> SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
>> >> Exception in thread "JavaFX Application Thread"
>> >> java.lang.StackOverflowError
>> >> at java.util.Hashtable.containsKey(Unknown Source)
>> >> at
>> >>
>> org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
>> >> at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
>> >> at
>> >>
>> org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
>> >> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>> >> at org.apache.log4j.Category.<init>(Category.java:56)
>> >> at org.apache.log4j.Logger.<init>(Logger.java:36)
>> > > > I've found only few references of this error on the net (e.g.
>> > http://www.slf4j.org/codes.html#multiple_bindings,
>> >
>> http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings
>>
>> > and
>> >
>> http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin,
>>
>> > but none of the proposed solutions seem applicable : there's no
>> > dependency defined in the POM, there is no conflict on the classpath
>> (as
>> > the bindings stem apparently twice from the same plugin) .
>> > Any idea of how to solve this ... ? Perhaps it's more of a question
>> > regarding log4j ... ?
>> > > Thomas
>> >
>
>
|
|
| | | | | | | |
Goto Forum:
Current Time: Wed Feb 05 12:46:27 GMT 2025
Powered by FUDForum. Page generated in 0.03742 seconds
|