0

如果我在下面有 log4j 设置。

我反对:

org.berlin2.Mycode.info("某事");

log4j.rootLogger=DEBUG,ConsoleAppender,LifeSimAppender
log4j.logger.org.berlin2=DEBUG,ConsoleAppender,LifeSimAppender

... log4j 定义是否正确,会发生什么?LifeSimAppender 写入文件。ConsoleAppender 是控制台附加程序。我只想写入文件一次。

上述定义与以下定义有什么区别:

log4j.rootLogger=DEBUG,ConsoleAppender,LifeSimAppender
log4j.logger.org.berlin2=DEBUG

在第一种情况下,我是否需要明确定义“附加程序”。

4

1 回答 1

-1

我用第一个“DEBUG,ConsoleAppender,LifeSimAppender”尝试了它,我得到了以下错误:

og4j:ERROR Could not find value for key log4j.appender.ConsoleAppender
log4j:ERROR Could not instantiate appender named "ConsoleAppender".
log4j:ERROR Could not find value for key log4j.appender.LifeSimAppender
log4j:ERROR Could not instantiate appender named "LifeSimAppender".
log4j:WARN No appenders could be found for logger (com.ali.play.Test).
log4j:WARN Please initialize the log4j system properly.

我尝试了第二个,然后收到以下警告:

log4j:WARN No appenders could be found for logger (com.ali.play.Test).
log4j:WARN Please initialize the log4j system properly.

我建议查看 log4j 网站以设置属性文件。这是给你的链接

于 2013-06-11T21:02:30.230 回答