找不到记录器(log4j)的附加程序? [英] No appenders could be found for logger(log4j)?

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

问题描述

我已将 log4j 放入构建路径,但在运行应用程序时收到以下消息:

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?

推荐答案

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

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();

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

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天全站免登陆