Showing posts with label log4j. Show all posts
Showing posts with label log4j. Show all posts

Thursday, May 14, 2009

JUnit, log4j And Eclipse

If you want Eclipse to pick up your log4j configuration file when you run JUnit tests from within Eclipse you can:
  1. Right-click on a test class.
  2. Select Run as --> Run configurations...
  3. Select the Classpath tab
  4. Select the home directory of you project and Advanced
  5. Then Add folder and add the folder with the configuration file and you're done.
This will configure the test file's JUnit run options.

If you want to configure all test classes with the same optoins... uhmm... stay tuned. I'll be back.

Tuesday, September 09, 2008

Configuring the Class Path When Testing in Eclipse

If you're testing from within Eclipse and are using Apache Commons Logging + log4j and you get the message:
log4j:WARN No appenders could be found for logger

you can let log4j know about the location of the log4j configuration file adding the directory where that file can be found this way:

Right click on the test class and choose Properties --> Run/Debug Settings
Select the file.
Click on Edit and select the Classpath tab.
Select the first item in User Entries, then Advanced, then Add Folders and you're done.

Thursday, March 22, 2007

Using Apache Commons Logging and Log4j

It's as easy as this:
  1. Download the latest and the greatest from Log4J.
  2. Download the latest and the greatest from Apache Commons Logging.
  3. Add the libraries to the $CLASSPATH.
  4. Write a Log4J properties file called log4j.properties and place it in a directory in the $CLASSPATH.
  5. You can now start logging in a class simply obtaining a logger with:
    1. private static final Log log = LogFactory.getLog(YourClass.class);
  6. and using it:
    1. log.info("your logging comment");