log4j在有log4j.properties的情况下在控制台提示如下错误:
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 [java.net.URLClassLoader@6a6824be] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ParallelWebappClassLoader
context: j2eeHW0602_war_exploded
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@6a6824be
].
log4j: ERROR Could not instantiate appender named "stdout".
log4j.properties文件如下:
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.properties文件存在于resources文件夹下
原因是appender和consoleAppender两个文件的classloader不一致。
你自己的war包,是不是包含了log4j的lib? 建议把它删除,放到tomcat目录的lib文件夹