java log4j 配置了不打印,log4j日志不正常,不输出到控制台问题

本文介绍了当使用MyEclipse2014进行单元测试时,控制台不再显示Log4j的日志信息的问题及解决方法。通过在VM参数中加入-Dlog4j.debug或指定log4j配置文件路径,可以解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值