Log4j Debug记录
log4j:WARN No appenders could be found for logger
错误提示信息
1 2 3
| log4j:WARN No appenders could be found for logger (demo.Log4jExample). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
|
配置文件内容
/Log4jDemo/src/log4j.properties1 2 3 4 5 6 7 8 9 10 11
| Log4j.rootLogger = DEBUG, FILE
Log4j.appender.FILE=org.apache.Log4j.FileAppender Log4j.appender.FILE.File=htmlLayout.html
Log4j.appender.FILE.layout=org.apache.Log4j.HTMLLayout Log4j.appender.FILE.layout.Title=HTML Layout Example Log4j.appender.FILE.layout.LocationInfo=true
|
解决方案
配置文件写错了,包名应该小写开头,将上述的Log4j
改成log4j
:
# Define the root logger with appender file
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=htmlLayout.html
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.HTMLLayout
log4j.appender.FILE.layout.Title=HTML Layout Example
log4j.appender.FILE.layout.LocationInfo=true