问题:我的myeclipse 2014由于一些原因不打印console日志。

解决方法:

1. 在运行的VM的参数里面增加-Dlog4j.debug 打印出log4j的测试信息。

2. 或者在VM参数里面强制增加log4j配置文件地址:-Dlog4j.configuration=log4j-config_folder/log4j.xml

一般你应该通过第一步找到原因然后根据情况解决

如何加参数:

1. 如果你是用的run/debug

右键->run/debug下面有一个run configurations/debug configurations->(x)=Arguments->下方有个VM arguments: 把参数加到里面,选apply和run/debug就可以了。

2. 如果你是用的myeclipse,要在Tomcat->Tomcat n.x->JDK->Optional Java VM arguments下增加-Dlog4j.debug

原文:http://stackoverflow.com/questions/3501355/log4j-output-not-displayed-in-eclipse-console

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.

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

}

}

Details:

log4j-1.2.6.jar

junit-4.6.jar Eclipse

IDE for Java Developers, Version:

Helios Release, Build id:

20100617-1415

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐