#--------------------------------
#
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:%d{ddMMMyy 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.
eclipse中用 log4j 控制台不显示日志 ,配置如下:
1. 在运行的VM的参数里面增加-Dlog4j.debug 打印出log4j的测试信息。2. 或者在VM参数里面强制增加log4j配置文件地址: -Dlog4j.configuration=log4j- config_folder\/log4j.xml 一般你应该通过第一步找到原因然后根据情况解决 如何加参数:如果你是用的run\/debug 右键->run\/debug下面有一个run configuratio...
java log4j 无法输出到控制台
log4j日志级别 log4j配置 log4j输出控制台失败 log4j不输出到控制台 控制台输出日志 log4j输出到文件 log4j保存到数据库 log4j保存到日志文件 log4j输出到控制台 其他类似问题2015-02-07 log4j仅输出控制台,不输出到日志文件文件 3 2015-07-09 eclipse中用 log4j 控制台不显示日志 ,配置如下... 2 ...
eclipse运行时报错信息如何写入日志文件
你好:这个的话,你可以配置log4j.xml文件的,来进行日志输入,然后每个文件中调用Log.info就可以了 备注:日志输出级别的话可以使debug、info、error、warn四中,在xml中配置对应的输出级别就可以了 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration SYSTEM "log4j.dtd" PUBLIC "-\/\/...
在eclipse中写完了log4j.properties文件,保存时出了如下提示,请高手指 ...
右键log4j.properties--->properties--->text file encoding --->other 调UTF-8
java的日志输出到哪里了
1.用eclipse等开发工具的话,日志会在控制台输出!2.web项目的话,在容器里面可以找到,如:tomcat,jBoss等 3 log4j的话,在配置文件中指定的是哪里,就是哪里
在启动Tomcat 的时候 出现了个错误 log4j:WARN please initialize t...
这个不是错误吧,只是警告,可以不去理它,不会影响程序运行。非要理的话将jvm目录修改为jre1.5.0_06\\bin\\client\\jvm.dll,重新运行tomcat试试。
请问,在eclipse spring如何添加配置文件
log4j.properties,放在项目的scr目录下 log4j.properties是要自己写的(新建一个log4j.properties文件),网上有很多参考模板.配置文件是xml格式的,在程序里面调用就可以了(注意路径)
如何看Eclipse的错误
可以在Eclipse的console控制台面板下面看 可以在编译之前打开problem面板,查看编译不通过的原因 Eclipse自己有一些日志文件,你可以到下面的目录下面去log文件,查看报错语句 乜可以使用一些日志工具,例如使用log4j来调试查看错误
控制台不打印??
利用out.println(String str)方法,可以实现JSP的打印功能。在JSP中,有九大隐式对象,其中一个是out。可以通过out.println(String str)的方法,来达到打印的目的。比如: out.println(“Hello World”);JSP页面就会自动生成内容为 “ Hello World ” 的 html 代码,相当于eclipse的控制台。
新手关于log4j.properties的问题,望各位大大相助.
放在src下的话就不用配置 否则得去web.xml里面配置一个Listener 参考:log4j.rootLogger=INFO,stdout,A1 控制台打印 log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 输出的信息 如果使用pattern布局就要指定的打印,通常指把电脑或其他...