-
1. Re: NoClassDefFoundError: org/apache/log4j/Layout
loky Jun 25, 2014 8:12 AM (in response to loky)I have exclude log4j dependancy in my maven project and insert org.ops4j.pax.logging reference.
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.7.2</version>
</dependency>
I see that the org.apache.log4j.Logger is not the same than the class in log4j dependancy ( missing removeAllAppenders / missing setLevel / ... ) that my project used.
-
2. Re: NoClassDefFoundError: org/apache/log4j/Layout
loky Jun 25, 2014 9:51 AM (in response to loky)I have try to find a workaround with log4J, but nothing works, any idea ?
-
3. Re: NoClassDefFoundError: org/apache/log4j/Layout
loky Jun 26, 2014 3:47 AM (in response to loky)I have identified more precisely what is wrong. With 2 simples use cases :
1/ If I do :
import org.apache.log4j.*;
public void Log(String logname) {
Logger filelogger = Logger.getLogger(logname);
filelogger.info("HELLO");
}
==> Everything is fine
2/ If I do :
public void Log(String logname) {
Logger filelogger = Logger.getLogger(logname);
filelogger.info("HELLO");
filelogger.removeAllAppenders();
}
==> Aoutch
Caused by: java.lang.NoSuchMethodError: org.apache.log4j.Logger.removeAllAppenders()V
at com.ericsson.mediation.core.bean.LoggerWrapper.Log(LoggerWrapper.java:78)[265:XXXXXXXXXXX:1.0.0]
I got the felling that in the karaf context, the org.apache.log4j.Logger is not the "real one" and indeed this is a lot of Logger class declared
(via a find-class Logger)
I would like to know if there is a way to tell to org.ops4j.pax.logging.pax-logging-XXX to use the " real " one ?
Thanks for your help
JF