Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 9371 invoked from network); 17 Feb 2003 14:59:57 -0000 Received: from stoker1out.webasto.de (194.59.2.39) by daedalus.apache.org with SMTP; 17 Feb 2003 14:59:57 -0000 Received: from swsex2.wan.de.web-int.net by stoker1out.webasto.de via smtpd (for daedalus.apache.org [208.185.179.12]) with SMTP; 17 Feb 2003 14:59:59 UT Received: by swsex2.wan.de.web-int.net with Internet Mail Service (5.5.2653.19) id ; Mon, 17 Feb 2003 15:50:31 +0100 Message-ID: <2D5BBBE40DAF3F468DD94EFA87284C8402670C56@sdestoex1.sto.de.web-int.net> From: Maher Martin To: 'Jakarta Commons Users List' Subject: [Logging] Error using logging with Unit Tests Date: Mon, 17 Feb 2003 15:59:51 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I'm having problems with the logging component in conjunction with Unit Tests (JUnit). Within a testCase I cannot use the logging component. I keep getting the error: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log I looked at the class Log4JCategoryLog and it clearly does implement the class Log. Below you can find the full stack trace as well as a sample Unit Test Class. Note: - The Main method within the test class does not throw any exception, however the testCase does. - I have not explicitly specified which Log Implementation to use, however Log4J is available within the classpath. thanks, Martin Maher ############## Exception: 0 [main] INFO part.TestLogger - Test 1 org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja va:555) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja va:289) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja va:259) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390) at com.webasto.cimload.transformer.part.TestLogger.outputLogMessage(TestLogger. java:44) at com.webasto.cimload.transformer.part.TestLogger.testA(TestLogger.java:36) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:166) at junit.framework.TestCase.runBare(TestCase.java:140) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at junit.swingui.TestRunner$17.run(TestRunner.java:644) ############## Class: package com.webasto.cimload.transformer.part; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import junit.framework.TestCase; import junit.framework.TestSuite; public class TestLogger extends TestCase { public TestLogger(String _name) { super(_name); } public void testA() { try { outputLogMessage("Test 2"); } catch(Exception e) { e.printStackTrace(); } } public static void outputLogMessage(String msg) { Log log = LogFactory.getLog(TestLogger.class); log.info(msg); } public static void main(String[] argv) { outputLogMessage("Test 1"); String[] testCaseList = {TestLogger.class.getName()}; junit.swingui.TestRunner.main(testCaseList); } }