idea提示log4j:WARN No appenders could be found for logger

我们先看下idea控制台提示的错误信息

控制台打印错误提示告诉我们,找不到记录器的附加程序,换句话说程序找不到日志输出配置文件

这里是apache官网给出的解释

*解决方法

resources下创建名为log4j.properties的文件不要在src下创建,可能会出现一些问题

将下面内容复制粘贴到log4j.properties文件内

log4j.rootLogger=INFO, stdout, D

# Console Appender

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n

# Custom tweaks

log4j.logger.com.codahale.metrics=WARN

log4j.logger.com.ryantenney=WARN

log4j.logger.com.zaxxer=WARN

log4j.logger.org.apache=WARN

log4j.logger.org.hibernate=WARN

log4j.logger.org.hibernate.engine.internal=WARN

log4j.logger.org.hibernate.validator=WARN

log4j.logger.org.springframework=WARN

log4j.logger.org.springframework.web=WARN

log4j.logger.org.springframework.security=WARN

# log file

log4j.appender.D = org.apache.log4j.DailyRollingFileAppender

r# 日志输出地址

log4j.appender.D.File = 日志输出地址

log4j.appender.D.Append = truelog4j.appender.D.Threshold = DEBUG

log4j.appender.D.layout = org.apache.log4j.PatternLayout

log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

*如有错误欢迎指出

你可能感兴趣的:(idea提示log4j:WARN No appenders could be found for logger)