Topic: 如何在junit test case中使用log4j输出日志信息

  Print this page

1.如何在junit test case中使用log4j输出日志信息 Copy to clipboard
Posted by: dongzg
Posted on: 2003-12-18 14:44

在test case中使用log4j不能输出log4j的日志,怎么解决?

2.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: jbwang
Posted on: 2003-12-18 21:32

<junit printsummary="withOutAndErr" fork="yes">

3.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: dongzg
Posted on: 2003-12-19 14:57

这个参数在哪里设置啊,我是使用的jbuilder的test case,没有找到。

4.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: jbwang
Posted on: 2003-12-20 15:32

sorry,我说的是ant的。

jbuilder的test runner,是打印log4j的信息的。只要这些Log信息是打印到控制台的,就会在控制台显示。

5.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: dongzg
Posted on: 2003-12-20 16:46

下面是错误信息,请帮忙看一下,怎么解决,谢谢。

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [junit.runner.TestCaseClassLoader@1ee148b] whereas object of type

log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@e2eec8].

log4j:ERROR Could not instantiate appender named "stdout".

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [junit.runner.TestCaseClassLoader@1ee148b] whereas object of type

log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [sun.misc.Launcher$AppClassLoader@e2eec8].

log4j:ERROR Could not instantiate appender named "R".

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [junit.runner.TestCaseClassLoader@1ee148b] whereas object of type

log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@e2eec8].

log4j:ERROR Could not instantiate appender named "stdout".

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [junit.runner.TestCaseClassLoader@1ee148b] whereas object of type

log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [sun.misc.Launcher$AppClassLoader@e2eec8].

log4j:ERROR Could not instantiate appender named "R".

log4j:WARN No appenders could be found for logger (com.neusoft.util.Log).

log4j:WARN Please initialize the log4j system properly.


6.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: jbwang
Posted on: 2003-12-20 20:12

log4j.rootLogger = DEBUG, mylog
log4j.category.mycompany.package = DEBUG, mylog
log4j.additivity.mycompany.package = false

log4j.appender.mylog=org.apache.log4j.ConsoleAppender
log4j.appender.mylog.Target=System.out

给个例子吧。

7.Re:如何在junit test case中使用log4j输出日志信息 [Re: dongzg] Copy to clipboard
Posted by: dongzg
Posted on: 2003-12-22 11:13

多谢楼上的大力支持,不过问题还是没有解决。

我得日志记录在web应用中是没有问题的,每日在文件中记录,只是在使用junit来作单元测试的时候,总是不能输出日志。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923