没有找到记录器(log4j)的追加者? [英] No appenders could be found for logger(log4j)?

查看:158
本文介绍了没有找到记录器(log4j)的追加者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把log4j放到我的buildpath,但是当我运行我的应用程序时,我收到以下消息:

  log4j:WARN没有找到记录器(dao.hsqlmanager)的追加者。 
log4j:WARN请正确初始化log4j系统。
log4j:WARN有关详细信息,请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig。

这些警告是什么意思?

解决方案

这个简单介绍log4j 指南有点旧,但仍然有效。



该指南将为您提供一些信息关于如何使用记录器和追踪器。






只是为了让你走,你有两个简单的方法可以采取。 p>

首先是将这行添加到你的主要方法:

  BasicConfigurator.configure(); 

第二种方法是添加此标准 log4j.properties (取自上述指南)文件到您的类路径:

 #设置根记录器级别为DEBUG及其唯一的追加者为A1。 
log4j.rootLogger = DEBUG,A1

#A1设置为ConsoleAppender。
log4j.appender.A1 = org.apache.log4j.ConsoleAppender

#A1使用PatternLayout。
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern =% - 4r [%t]%-5p%c%x - %m %n


I have put log4j to my buildpath, but I get the following message when I run my application:

log4j:WARN No appenders could be found for logger (dao.hsqlmanager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

What do these warnings mean? Whats the appender here?

解决方案

This Short introduction to log4j guide is a little bit old but still valid.

That guide will give you some information about how to use loggers and appenders.


Just to get you going you have two simple approaches you can take.

First one is to just add this line to your main method:

BasicConfigurator.configure();

Second approach is to add this standard log4j.properties (taken from the above mentioned guide) file to your classpath:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

这篇关于没有找到记录器(log4j)的追加者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆