Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure org.apache.log4j.ConsoleAppender with custom classloader

I have a java class which creates a custom classloader based on javassist class loader on start up and then run the real program class. I'm getting the following error:

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a        
"org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by 
log4j:ERROR [javassist.Loader@6f97b10a] whereas object of type 
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by 
[java.net.URLClassLoader@5b414a8d].
log4j:ERROR Could not instantiate appender named "stdout".

The problem is related to the fact that one object is created by the original classloader while the other is created by the custom one.
Is there a way to resolve this error?

Thanks in advance,
Avner

like image 409
Avner Levy Avatar asked Sep 13 '12 11:09

Avner Levy


1 Answers

Please try to set -Dlog4j.ignoreTCL=true, hope it helps. a simular issue about log4j

like image 59
Sola Yang Avatar answered Oct 15 '22 17:10

Sola Yang