log4j报错:ERROR Could not find value for key log4j.appender.Console
使用Maven包管理工具,按住shift后点击log4j的依赖,可以直接进入log4j-1.2.17.pom中,说明包导入成功;
log4j.properties文件中内容如下:
#日志的输入级别和输出位置
log4j.rootLogger = DEBUG,Console
#配置此类可以将log日志输出到控制台
log4.appender.Console = org.apache.log4j.ConsoleAppender
#自定义的日志布局
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
#自定义的日志布局格式
#%d : 查询日志的时间
#%t : 产生的日志所处线程的线程名称
#%p : 输出的日志的级别,5表示输出的字符至少五个,-表示如果输出的字符少于五个,少的部分由空格补齐并且补充的空格在右边,
# 若不加-号,则补齐的空格在左边
#%c : 输出的日志所处的类的全名
#%m : 输出日志时的附加信息
#%n : 换行
log4j.appender.Console.layout.ConversionPattern = %d [%t] %-5p [%c] - %m%n
#为某个包单独设置输出级别,org.apache可以是任意的包名
#log4j.logger.org.apache = INFO报错如下:
Connected to server
[2018-05-16 09:21:44,533] Artifact micromessage:war exploded: Artifact is being deployed, please wait...
16-May-2018 09:21:45.496 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2018-05-16 09:21:45,566] Artifact micromessage:war exploded: Artifact is deployed successfully
[2018-05-16 09:21:45,566] Artifact micromessage:war exploded: Deploy took 1,033 milliseconds
command = null
description = null
log4j:ERROR Could not find value for key log4j.appender.Console
log4j:ERROR Could not instantiate appender named "Console".
log4j:WARN No appenders could be found for logger (Message.selectMessageList).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.