开发者社区> 问答> 正文

JFinal启动log4j报错?报错

@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

展开
收起
爱吃鱼的程序员 2020-06-14 17:01:04 718 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    看了这个帖子弄好了。<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



    弄好了。加了slf4j-api.jar和slf4j-log4j.jar就好了。还是会报错。一样的错误。

    2020-06-14 17:01:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载