gpt4 book ai didi

java - 为什么我收到错误 "ERROR Could not find value for key log4j.appender.CONSOLE"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:58:04 24 4
gpt4 key购买 nike

我使用的是 log4j 版本 1.2.15,在执行代码时我能够获取日志文件和 .html 但在控制台中它会生成以下错误:

log4j:ERROR Could not find value for key log4j.appender.CONSOLE
log4j:ERROR Could not instantiate appender named "CONSOLE".

我正在使用以下属性文件:

log4j.rootLogger= INFO,CONSOLE,R,HTML,TTCC

//Here we define the appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.TTCC=org.apache.log4j.RollingFileAppender
log4j.appender.HTML=org.apache.log4j.FileAppender

// Here we define log file location
log4j.appender.R.File=./log/testlog.log
log4j.appender.TTCC.File=./log/testlog.log
log4j.appender.HTML.File=./log/aplication.html

// Here we define the layout and pattern
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern= [%t:%p] %c: %m%n

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern= %d - %c -%p -%m%n

log4j.appender.TTCC.layout=org.apache.log4j.TTCCLayout
log4j.appender.TTCC.layout.DateFormat=ISO8601

log4j.appender.HTML.layout=org.apache.log4j.HTMLLayout
log4j.appender.HTML.layout.Title=Application log
log4j.appender.HTML.layout.LocationInfo= true

此外,我在日志文件中不明白为什么它会用“ma​​in”和“demo”打印两次同一行,请检查以下内容:

015-08-10 21:25:08,921 - demo -INFO -New driver instantiated
2015-08-10 21:25:08,921 [main] INFO demo - New driver instantiated
2015-08-10 21:25:09,000 - demo -INFO -Implicit wait applied on the driver for 10 seconds
2015-08-10 21:25:09,000 [main] INFO demo - Implicit wait applied on the driver for 10 seconds
2015-08-10 21:25:42,156 - demo -INFO -Web application launched
2015-08-10 21:25:42,156 [main] INFO demo - Web application launched

谁能告诉我确切的问题是什么?另外,我是第一次通过查看教程来尝试。所以,请帮助我。

最佳答案

您的根记录器定义为 CONSOLE(全部大写)。但你发起log4j.appender 用于console(小写)。

根据 log4j documentation

Logger names are case-sensitive

换行

log4j.rootLogger= INFO,CONSOLE,R,HTML,TTCC

log4j.rootLogger= INFO,console,R,HTML,TTCC

为了让 log4j 正确初始化。

关于java - 为什么我收到错误 "ERROR Could not find value for key log4j.appender.CONSOLE"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31947213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com