You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Dyson, Steve" <SD...@thalesnavigation.com> on 2003/01/02 18:23:22 UTC

Interaction between Log4J and JUnit

I am trying to sort out an interaction between Log4J and the JUnit swing
interface. 

I have distilled the problem down into 4 very small source files
(ExamplePrint.java, ExampleLog4J.java, ExamplePrintTest.java and
ExampleLog4Jtest.java), and an xml configuration file. The ExamplePrint is a
simple class with a constructor and a one line method, it calls
System.out.println(). The ExampleLog4J is the equivalent that calls
logger.info() instead. The other files are simple JUnit exercisers.

The following command lines work a expected...
  
   	java  example.ExamplePrint
   	java  example.ExampleLog4J

   	java junit.textui.TestRunner example.ExamplePrintTest
   	java junit.textui.TestRunner example.ExampleLog4JTest

   	java junit.swingui.TestRunner example.ExamplePrintTest

The following line

   	java junit.swingui.TestRunner example.ExampleLog4Jtest

causes the following log4j  error messages

		log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object
is not assignable to a "org.apache.log4j.spi.Configurator" variable
		log4j:ERROR The class "org.apache.log4j.spi.Configurator"
was loaded by
		log4j:ERROR [junit.runner.TestCaseClassLoader@cd66ea]
whereas object of type
		log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was
loaded by [sun.misc.Launcher$AppClassLoader@2f6684].
		log4j:ERROR Could not instantiate configurator
[org.apache.log4j.xml.DOMConfigurator].
		log4j:WARN No appenders could be found for logger
(example.ExampleLog4J).
		log4j:WARN Please initialize the log4j system properly.


Please can anyone let me know what is happening!

Regards (and Happy New Year to all)
Steve.

PS: The source code,  xml and log files are available for inspection if
needed.







--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>