问题:我的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