`

log4j:WARN No appenders could be found for logger 解决方案

 
阅读更多
log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory). 
log4j:WARN Please initialize the log4j system properly.

这个问题是因为我们的log4j.properties文件配置不够完整,所以我们给它配置齐了就不会再出现这个问题。


完整配置如下:


log4j.rootLogger=CONSOLE,FILE 
log4j.addivity.org.apache=true 
 
# 应用于控制台 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 
log4j.appender.CONSOLE.Threshold=INFO 
log4j.appender.CONSOLE.Target=System.out 
log4j.appender.CONSOLE.Encoding=GBK 
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 
log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 
 
# 每天新建日志 
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.A1.File=C:/log4j/log 
log4j.appender.A1.Encoding=GBK 
log4j.appender.A1.Threshold=DEBUG 
log4j.appender.A1.DatePattern='.'yyyy-MM-dd 
log4j.appender.A1.layout=org.apache.log4j.PatternLayout 
log4j.appender.A1.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L : %m%n 
 
#应用于文件 
log4j.appender.FILE=org.apache.log4j.FileAppender 
log4j.appender.FILE.File=C:/log4j/file.log 
log4j.appender.FILE.Append=false 
log4j.appender.FILE.Encoding=GBK 
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 
 
# 应用于文件回滚 
log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender 
log4j.appender.ROLLING_FILE.Threshold=ERROR 
log4j.appender.ROLLING_FILE.File=rolling.log 
log4j.appender.ROLLING_FILE.Append=true 
log4j.appender.CONSOLE_FILE.Encoding=GBK 
log4j.appender.ROLLING_FILE.MaxFileSize=10KB 
log4j.appender.ROLLING_FILE.MaxBackupIndex=1 
log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.ROLLING_FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 
 
#自定义Appender 
log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender 
log4j.appender.im.host = mail.cybercorlin.net 
log4j.appender.im.username = username 
log4j.appender.im.password = password 
log4j.appender.im.recipient = yyflyons@163.com 
log4j.appender.im.layout=org.apache.log4j.PatternLayout 
log4j.appender.im.layout.ConversionPattern =[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 
 
#应用于socket 
log4j.appender.SOCKET=org.apache.log4j.RollingFileAppender 
log4j.appender.SOCKET.RemoteHost=localhost 
log4j.appender.SOCKET.Port=5001 
log4j.appender.SOCKET.LocationInfo=true 
# Set up for Log Facter 5 
log4j.appender.SOCKET.layout=org.apache.log4j.PatternLayout 
log4j.appender.SOCET.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD]%n%c[CATEGORY]%n%m[MESSAGE]%n%n 
# Log Factor 5 Appender 
log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender 
log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000 
 
# 发送日志给邮件 
log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender 
log4j.appender.MAIL.Threshold=FATAL 
log4j.appender.MAIL.BufferSize=10 
log4j.appender.MAIL.From=yyflyons@163.com 
log4j.appender.MAIL.SMTPHost=www.wusetu.com 
log4j.appender.MAIL.Subject=Log4J Message 
log4j.appender.MAIL.To=yyflyons@126.com 
log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout 
log4j.appender.MAIL.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 


再次运行你的程序,你会发现Log4j的警告消失了。不过发现以前的Log4j控制台信息也没有了,其实只要把上面详细配置的log4j.rootLogger=CONSOLE,FILE改为log4j.rootLogger=DEBUG,CONSOLE,FILE,你就发现,控制台信息又回来了。
分享到:
评论

相关推荐

    log4j:WARN No appenders could be found for logger (org.springframework.context.s

    NULL 博文链接:https://wait7758521.iteye.com/blog/1933964

    log4j日志报错解决办法

    首先,错误信息"log4j:WARN No appenders could be found for logger"表明Log4j找不到任何日志输出的目标,也就是没有设置日志appender。日志appender是Log4j用来定义日志输出目的地的组件,比如控制台、文件、邮件...

    log4j.properties

    1.log4j:WARNNoappenderscouldbefoundforlogger(org.apache.hadoop.util.Shell). 2.log4j:WARNPleaseinitializethelog4jsystemproperly. 3.log4j:WARNSeehttp://logging.apache.org/log4j/1.2/faq....

    JAVACCC.DLL

    log4j:WARN No appenders could be found for logger org apache commons beanutils ConvertUtils 出现这个错误 在web inf classes路径下加了log4j properties文件还是这个错误log4j:WARN Please initialize the ...

    quartz log4j

    log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog). log4j:WARN Please initialize the log4j system properly.

    log4j-appenders

    为解决这个问题,log4j引入了ASYNC Appender,它通过异步处理日志事件,将日志写入操作放到单独的线程中执行,从而避免阻塞主线程,提高应用程序的响应速度。 ASYNC Appender的核心在于它使用了`java.util....

    log4j-1.2.14.jar

    报错WARN No appenders could be found for logger 或 WARN Please initialize the log4j system properly时需要引入的包。用法可以参考https://blog.csdn.net/u010912188/article/details/79761894

    schemacrawler-hive:适用于Apache Hive的SchemaCrawler插件

    模式爬虫配置单元 不幸的是,到目前为止, 似乎是不切实际的。 从hive-1.1.0(CDH5.4)开始,...log4j:WARN No appenders could be found for logger (org.apache.hive.jdbc.Utils). log4j:WARN Please initialize the

    clj-hbase:小型且不完整的 hbase 0.98.3 clojure 包装器

    clj-hbase 这是一个用于 hbase 0.98.3 的小型且仍然不完整的 clojure 包装器 用法 假设我们有一个带有列族“byte-data...log4j:WARN No appenders could be found for logger ( org.apache.hadoop.metrics2.lib.Mutabl

    hadoop-2.6.0-hadoop.dll-winutils.exe

    log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See ...

    hanging-chad:演示两个ZK客户可以一次认为自己是领导者

    玩具应用程序可证明参加动物园管理员领导者选举食谱的多个客户可以随时认为自己是领导者。 建造 建立: $ ../gradlew jar 这将在build / libs中创建...log4j:WARN No appenders could be found for logger (org

    log4j简单配置

    例如,在Spring框架的应用中,如果没有正确配置log4j,就可能出现“log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext)”这类警告信息。...

    Java记录文档

    当出现"log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)"这样的警告时,这意味着log4j没有找到任何日志输出目标。这通常是因为日志配置文件未被正确加载。解决...

    struts2驱动包

    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 2009-8-29 14:02:12 org.apache.catalina.core....

    tomcat排错经典案例之404.docx

    log4j:WARN No appenders could be found for logger (org.apache.mons.digester.Digester). log4j:WARN Please initialize the log4j system properly. 2009-11-06 21:39:17 org.apache.catalina.core....

Global site tag (gtag.js) - Google Analytics