[slf4j-user] Logging java.lang.NoSuchMethodError Exception?

Ceki Gulcu listid at qos.ch
Thu Oct 23 10:47:55 CEST 2008


Hello Ole,

This is from http://slf4j.org/compatibility.html

Please note that in many cases incompatibility problems are caused by mixing 
different versions of slf4j artifacts. For example, if you are using 
slf4j-api-1.5.4.jar you should also use slf4j-simple-1.5.4.jar, using 
slf4j-simple-1.4.2.jar will not work. The same goes for all other SLF4J artifacts.

So, I would resume your dependencies on SLF4J *and* log4j as

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-log4j12</artifactId>
   <version>1.5.5</version>
</dependency>

This will pull in slf4j-api (v1.5.5) and log4j (v1.2.14) as well as 
slf4j-log4j12 (v1.5.5).

HTH,

Ole Ersoy wrote:
> Hi,
> 
> I'm trying to use SLF4J like this:
> 
> 	private static Logger slf4jLogger =  
> 		LoggerFactory.
> 		getLogger(Filter.class);
> 
> Resulting in this exception:
> failed; nested exception is java.lang.NoSuchMethodError: org.apache.log4j.Logger.log(Ljava/lang/String
> ;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V
> 
> If I instead use a logger defined with log4j everything works fine:
> 
> 	private static Logger log4jLogger = 
> 		Logger.
> 		getLogger(
> 			Filter.class);
> 
> Any ideas one why the exception occurs.  My dependencies look like this:
> 
> <!-- SLF4J  -->
>         <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>slf4j-log4j13</artifactId>
>             <version>1.0.1</version>
>         </dependency>
>         <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>slf4j-api</artifactId>
>             <version>1.5.5</version>
>         </dependency>
>         <dependency>
>             <groupId>log4j</groupId>
>             <artifactId>log4j</artifactId>
>             <version>1.2.9</version>
>         </dependency>        
> <!-- SLF4J  -->
> 
> TIA,
> Ole
> 
> 
> 
> 
> 
> 
> _______________________________________________
> user mailing list
> user at slf4j.org
> http://www.slf4j.org/mailman/listinfo/user

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch



More information about the slf4j-user mailing list