JFinal启动log4j报错

夜辰 发布于 2015/04/01 16:00
阅读 269
收藏 0

@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

加载中
1
夜辰
夜辰
看了这个帖子弄好了。http://www.oschina.net/question/1780165_157548。加上slf4j-api-1.6.1.jar、slf4j-log4j12-1.6.1.jar就好了。之前的项目没有用这两包也不会报错。
1
糊搞

看看这个:

log4j.rootLogger=DEBUG, 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:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n

# Output to the File
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=./jfinal.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n



夜辰
夜辰
弄好了。加了slf4j-api.jar和slf4j-log4j.jar就好了。
夜辰
夜辰
还是会报错。一样的错误。
返回顶部
顶部