@JFinal 你好,想跟你请教个问题:现在项目启动后log4j报错。报错信息如下:
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 [sun.misc.Launcher$AppClassLoader@2994363b] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebAppClassLoader=1139254871@43e7a657].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [sun.misc.Launcher$AppClassLoader@2994363b] whereas object of type
log4j:ERROR "org.apache.log4j.FileAppender" was loaded by [WebAppClassLoader=1139254871@43e7a657].
log4j:ERROR Could not instantiate appender named "file".
log4j配置如下:
log4j.rootLogger=WARN, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH🇲🇲ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
# Output to the File
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=./WebRoot/WEB-INF/BP.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH🇲🇲ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
看了这个帖子弄好了。<arel="nofollow">http://www.oschina.net/question/1780165_157548。加上slf4j-api-1.6.1.jar、slf4j-log4j12-1.6.1.jar就好了。之前的项目没有用这两包也不会报错。
看看这个:
<preclass="brush:c#;toolbar:true;auto-links:false;">log4j.rootLogger=DEBUG,stdout,filelog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%n%-d{yyyy-MM-ddHH:mm:ss}%n[%p]-[Thread:%t]-[%C.%M()]:%m%n#OutputtotheFilelog4j.appender.file=org.apache.log4j.FileAppenderlog4j.appender.file.File=./jfinal.loglog4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-ddHH:mm:ss}%n[%p]-[Thread:%t]-[%C.%M()]:%m%n版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。