Log4j 输出未显示在 Eclipse 控制台中 [英] Log4j output not displayed in Eclipse console
问题描述
出于某种原因,当我运行 JUnit 测试时,我的 Eclipse 控制台不再显示 Log4j INFO 和 DEBUG 语句.代码方面没有任何变化,应该是Eclipse配置的问题.
For some reason my Eclipse console no longer displays Log4j INFO and DEBUG statements when I run JUnit tests. In terms of code there hasn't been any change, so it must something to do with the Eclipse configuration.
我在单元测试中所做的一切如下,出于某种原因,Eclipse 控制台中仅显示 ERROR 语句.为什么?我该去哪里找线索?
All I do in my Unit test is the following and for some reason ONLY the ERROR statement is displayed in the Eclipse console. Why? Where shall I look for clues?
public class SampleTest
{
private static final Logger LOGGER = Logger.getLogger(SampleTest.class);
@Before
public void init() throws Exception
{
// Log4J junit configuration.
BasicConfigurator.configure();
LOGGER.info("INFO TEST");
LOGGER.debug("DEBUG TEST");
LOGGER.error("ERROR TEST");
}
}
详情:
- log4j-1.2.6.jar
- junit-4.6.jar Eclipse
- 面向 Java 开发人员的 IDE,版本:Helios 发布,构建 ID:20100617-1415
推荐答案
转到在 Eclipse 中运行配置,然后 -VM 参数添加以下内容:-Dlog4j.configuration=log4j-config_folder/log4j.xml
Go to Run configurations in your eclipse then -VM arguments add this: -Dlog4j.configuration=log4j-config_folder/log4j.xml
将 log4j-config_folder 替换为您的文件夹结构,其中包含您的 log4j.xml 文件
replace log4j-config_folder with your folder structure where you have your log4j.xml file
这篇关于Log4j 输出未显示在 Eclipse 控制台中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!