eclipse控制台不显示
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eclipse控制台不显示相关的知识,希望对你有一定的参考价值。
show view 调试过,点击了没一点反应,很奇怪,切换到debug模式下,控制台就可以显示,java ee 开发模式下没反应
1、进windows菜单 -> show view -> console2、还是windows菜单里面 -> preferences -> 打开左边的run/debug -> console。在两个show when... 前面打勾,如果已经是被选中的,就去掉选中,确定。然后再打开这里,把那两个show shen... 选中,确定,重启eclipse。 参考技术A 使用eclipse等IDE开发工具进行开发的时候,一般都需要在控制台中查看项目运行的日志,通过日志可以了解到项目运行的详细结果。如果console没有显示可以通过windows进行设置显示控制台。
1、控制台一般都是放在项目开发主界面的下面,这样方便进行查看项目运行的结果以及报错信息。
2、点击eclipse顶部导航中的windows选项,选择ShowView视图。显示视图界面。
3、将鼠标放在Show View上在右侧即可看到有一个Console控制台,点击选择即可在界面上显示控制台。
4、如果在Show View的右侧没有显示出Console,点击Other。从这里选择显示控制台。
5、直接在输入框中输入console关键字进行查询console控制台所在的位置,选择好之后,点击OK保存设置。
6、如果想通过选择的方式,点击General一般性,展开文件夹,在文件夹内就可以看到Console,点击选择之后,点击Ok即可进行保存。
eclipse中用 log4j 控制台不显示日志 ,配置如下:
#--------------------------------
#
log4j.rootLogger=INFO, stdout
log4j.logger.com.ibatis = DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource = DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner = DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate = DEBUG
log4j.logger.java.sql.Connection = DEBUG
log4j.logger.java.sql.Statement = DEBUG
log4j.logger.java.sql.PreparedStatement = DEBUG
log4j.logger.java.sql.ResultSet = INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#--------------------------------
#
log4j.rootLogger=INFO, stdout
log4j.logger.com.ibatis = DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource = DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner = DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate = DEBUG
log4j.logger.java.sql.Connection = DEBUG
log4j.logger.java.sql.Statement = DEBUG
log4j.logger.java.sql.PreparedStatement = DEBUG
log4j.logger.java.sql.ResultSet = INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
1. 在运行的VM的参数里面增加-Dlog4j.debug 打印出log4j的测试信息。
2. 或者在VM参数里面强制增加log4j配置文件地址: -Dlog4j.configuration=log4j-
config_folder/log4j.xml
一般你应该通过第一步找到原因然后根据情况解决
如何加参数:
如果你是用的run/debug
右键->run/debug下面有一个run configurations/debug configurations->(x)=Argument
s->下方有个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
java eclipse junit log4j
share|improve this questionedited Aug 17 '10 at
10:21leppie68.9k8106203asked Aug 17 '10 at 10:11javaExpert1242210
1 Did you already got the answer? Their is nearly every possible solution explained,
so it would be interesting, whether one helped. – user357206Sep 2 '10 at 7:52
add a comment
11 Answers
active oldest votes
up vote 11 down vote
Go to Run configurations in your eclipse then -VM arguments add this: -
Dlog4j.configuration=log4j-config_folder/log4j.xml
replace log4j-config_folder with your folder structure where you have your log4j.xml
file
share|improve this answeranswered Aug 17 '10 at 12:24Huzi--- Javiator51945
Thanks for the suggestion. This way it worked! Although I'm still a bit annoyed for
two reasons: 1) I thought if I used the BasicConfigurator.configure() I didn't have to
bother having the log4j.properties 2) When I run a simple JUnit test I just want to right
clik and "run", not having to define a configuration I've tried again my original test,
but adding the following line to see if it was using some variable defined somewhere
in Eclipse: System.out.println(System.getProperty("log4j.configuration")); But it prints
out "null" – javaExpertAug 17 '10 at 13:50 hmmm.. interesting.. k ll get back to yu –
Huzi--- Javiator Aug 18 '10 at 8:59
add a comment
up vote 8 down vote
Look in the log4j.properties or log4j.xml file for the log level. It's probably set
to ERROR instead of DEBUG
share|improve this answeranswered Aug 17 '10 at 10:15Aaron Digulla153k36236405
1 Thanks for the reply Aaron. I have checked the log4.properties and it was set on
INFO. I have now changed it to DEBUG, but it doesn't make any difference. Any
other idea? log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%t:%dddMMMyy HH:mm:ss.SSS
%-5p (%F:%L) %m%n – javaExpert Aug 17 '10 at 10:2310 add -Dlog4j.debug to your
VM environment startup properties to have log4j print out it's debugging info -
perhaps a different log4j configuration file is being picked up on the classpath (such
as one bundled inside a JAR) than the one you intend – matt b Aug 17 '10 at
11:35 @javaExpert: In that case, it find a different log4j.properties somewhere on
the classpath. Look into your JARs, too! – Aaron Digulla Aug 17 '10 at 12:23
add a comment
up vote 5 down vote
One thing to note, if you have a log4j.properties file on your classpath you do not
need to call BasicConfigurator. A description of how to configure the properties file
is here.
You could pinpoint whether your IDE is causing the issue by trying to run this class
from the command line with log4j.jar and log4j.properties on your classpath.
参考技术A 你好;日志的话需要用到以下三个包,你的包不全,可以先把包添加全了,然后就可以了;E:\Java\包\Hibernate配置的压缩包\slf4j-log4j12-1.5.8.jar
E:\Java\包\Hibernate配置的压缩包\log4j-1.2.15.jar
E:\Java\包\Hibernate配置的压缩包\slf4j-api-1.5.8.jar本回答被提问者采纳
以上是关于eclipse控制台不显示的主要内容,如果未能解决你的问题,请参考以下文章