How to view the output logger file created by my code ?
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Thursday, April 11, 2002 05:49 PM

I am a beginner with unit testing. I have found sample code that uses a logger in the following way to log the various stages of testing. Can anyone tell me how I can view the contents of this log file thus created by this code ?

protected void setUp()


logger = ABCLogManager.getInstance().getLogger("");


dbm = ABCDBManager.getInstance();"LOGGER LOGGING");"SETUP complete");


Re: How to view the output logger file created by my code ?

Posted By:   Thomas_SMETS  
Posted On:   Tuesday, April 16, 2002 04:19 PM

I usually do it this way :

// Always locate the tests in the same package but
// in a sub directory named test
// I break the mapping src-code dir / package-name

package test.gui.jtable;

// With Log4J version 1.2
import org.apache.log4j.Category;
import org.apache.log4j.BasicConfigurator;

import junit.framework.*;

public class TestDataModel
extends TestCase
// In test case everything is public
// faster & easier

public DataModel dm = null;
public Object[][] data = null;
public Category log = null;
public static int Loaded = 0;

public TestDataModel (String aTestToRun)
super (aTestToRun);
BasicConfigurator.resetConfiguration ();
// Everything is printed to the System.out
// but categorized

BasicConfigurator.configure ();

// You may alternively pass your own appender !!!
log = Category.getInstance (TestDataModel.class); ("TestDataModel instanciated with " + aTestToRun);

public void setUp ()
data = getData ();
dm = DataModel.getInstance(data);

public void tearDown ()
if (data != null)
for (int i = 0; i for (int j = 0; j data[i][j] = null;
data = null;

public void testEmpty ()
{ ("testEmpty running");

public void testGetRowCount ()
assertTrue ( "Not the right nbr of rows...",
data.length == dm.getRowCount) );

public static TestSuite suite ()
TestCase test = null;
TestSuite suite = new TestSuite();
test = new TestDataModel("testEmpty");
suite.addTest (test);
test = new TestDataModel("testGetRowCount ");
suite.addTest (test);

return suite;

public static void main (String[] args)
// You may alternatively place the Basicconfigurator
// here but you will also have some potential issues (TestDataModel.class);

public static Object[][] getData()
new String[][]
{"AICD1", "U.S.A.", "New York, La Guadia"},
{"AICD2", "Canada", "Vancouver"},
{"AICD3", "Ivory Coast", "Ougaddougou"},
{"AICD4", "France", "Paris CdG"},
{"AICD5", "France", "Marseille"},
{"AICD6", "France", "Toulouse"},
{"AICD7", "France", "Nice"},
{"AICD8", "Germany", "Franckfurt"},
{"AICD9", "Germany", "Dusseldorf"},
{"AICD10", "Germanyw", "Berlin"},
{"AICD11", "Germany", "Stutgard"},
{"AICD12", "United Kingdom", "London Eatrow"}
} // made with

About | Sitemap | Contact