Srivignesh
Srivignesh

Reputation: 357

Cassandra dependency changes during log4j2 migration

I am migrating my application from log4j to log4j2. For this I have replaced the jar files for log4j with log4j2 and updated the corresponding API calls to use the new jar.

We also have cassandra noSQL db which has slf4j-log4j12-1.7.6.jar as dependency which in turn uses log4j APIs. I would need to replace slf4j-log4j12-1.7.6.jar with a new jar which is compatible with log4j2. Can someone suggest the correct jar to be used?

I am getting below exception while building cassandra components.

Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level

at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)

Upvotes: 0

Views: 206

Answers (2)

rgoers
rgoers

Reputation: 9151

The NoClassDefFound error indicates SLF4J is looking for Log4j 1.x. You need to replace the slf4j-log4j12 jar with Log4j 2's log4j-slf4j-impl jar.

Upvotes: 2

Srivignesh
Srivignesh

Reputation: 357

This is resolved now by adding log4j-to-slf4j-2.9.1.jar and removing slf4j-log4j12-1.7.6.jar.

Below links helped.

https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html

http://slf4j.42922.n3.nabble.com/trouble-migrating-from-log4j-1-2-to-log4j-2-0-td4025759.html

Upvotes: 0

Related Questions