[异常]Java调用log4j警告问题

【异常提示】

log4j:WARN No appenders could be found for logger (com.gargoylesoftware.htmlunit.WebClient).
log4j:WARN Please initialize the log4j system properly.


【处理方法】

1. 在src文件夹下,创建文件"log4j.properties",其内容为:

### \u8BBE\u7F6E###
log4j.rootLogger = INFO,D
### \u8F93\u51FADEBUG \u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7\u5230=E://logs/error.log ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = INFO 
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern =  %m%n
2. log4j将会在目录下创建logs文件夹,并在文件夹下创建log.log文件做运行记录;同时每次运行时的报错将会消失

你可能感兴趣的:(异常;)