[slf4j-user] trouble migrating from log4j 1.2 to log4j 2.0

Urena, Jose M (JOSE) jose.urena at verizon.com
Tue Jul 29 16:41:58 CEST 2014


Look at the the log4j 2 manual
I believe it will be fixed when you include the log4j 2 -> 1.2 bridge for any code that cannot be changed to log4j2  or replace slf4j-api-1.7.7.jar/slf4j-log4j12-1.7.7.jar  with the log4j 2 -> SLF4J bridge (log4j-slf4j-impl-2.0.jar) for code using SLF4J

http://logging.apache.org/log4j/2.x/log4j-1.2-api/index.html
http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html

From: slf4j-user [mailto:slf4j-user-bounces at qos.ch] On Behalf Of niels
Sent: Tuesday, July 29, 2014 1:28 AM
To: User list for the slf4j project
Subject: Re: [slf4j-user] trouble migrating from log4j 1.2 to log4j 2.0

Hi,

just an idea:
slf4j-log4j12-1.7.7.jar sounds like a binding for log4j 1.2 not for log4j 2.0. So I would guess it's a wrong binding. No idea if there exists a 2.0 Binding. See http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/

Regards
Niels

2014-07-28 20:53 GMT+02:00 Mike Wertheim <mikew at hyperreal.org<mailto:mikew at hyperreal.org>>:
Hi,

I am trying to migrate my app from log4j 1.2 to log4j 2.0.  My app uses log4j directly, and it also uses a third party library that uses slf4j.

I put following jar files in my Classpath:
log4j-api-2.0.jar, log4j-core-2.0.jar
slf4j-api-1.7.7.jar, slf4j-log4j12-1.7.7.jar

When I try to start my app, the third party library's use of slf4j causes this exception to be thrown:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)

This is not surprising, since the log4j 2.0 migration page (http://logging.apache.org/log4j/2.x/manual/migration.html) says: "The main package in version 1 is org.apache.log4j, in version 2.0 it isorg.apache.logging.log4j"

Am I correct that the slf4j developers will need to make some modifications to slf4j to enable compatibility with log4j 2.0 (specifically, changing slf4j to look for the log4j classes in org.apache.logging.log4j rather than org.apache.log4j)?

Or is there some workaround to this issue that I can do now?


Thanks,
Mike

_______________________________________________
slf4j-user mailing list
slf4j-user at qos.ch<mailto:slf4j-user at qos.ch>
http://mailman.qos.ch/mailman/listinfo/slf4j-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20140729/e3f4bcbe/attachment.html>


More information about the slf4j-user mailing list