Reputation: 1033
My basic question is. How do I configure Netty to use slf4j in Spring? I keep getting the error below in Spring but not eclipse using the slf4j jars with the log4j bridge and api in the path. I am using Spring Tools suite, spring 3.2.3, and Netty 4 (post jboss).
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
The program fails at the line where I instantiate the connection group after I try setting the default logging factory.
I am really new to Netty and slf4j. I have been banging my head against this one for a while and done a bit of research on Stack Overflow and the internet. I managed to get Netty working with slf4j in eclipse and used the Internal Logger Factory. I tried configuring slf4j in a similar way to log4j (A properties file with appenders).
I used the following code for the InternalLoggerFactory in both of the following ways with the appropriate imports.
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
and
InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.getDefaultFactory());
These lines are placed immediately before my initialization of the connection group but I tried them in my Main App/Driver's main method as well.
Thanks for any help. I would and do really appreciate it.
Upvotes: 1
Views: 1404
Reputation: 120811
´org.slf4j.LoggerFactory´ is part of ´slf4j-api-1.75.jar´, so it is likely that you have some deployment problem. -- Check that this jar is really in the classpath of you application, or if you have an web application, then check that this jar is deployed to you application server.
One other thing (that is maybe not the cause of your problem) is that you have log4j-1.2.16.jar
and log4j-to-slf4j-2.0-beta8.jar
. This is will lead to other problems, because log4j-to-slf4j
is a log4j-to-slf4j bridge, that forward log4j loggers to slf4j. On the ohter hand you have the real log4j in your classpath too. I would remove log4j-1.2.16.16
. I hope this slf4j docu describe it a bit better than me.
An other point that brothers me, is that you use different version of slf4j. I strongly recommend to use the same version for all slf4j libs!
Upvotes: 1