Configure Log4J in Eclipse IDE

It would be nice to see debug message when debugging code or run unit test in IDE.

I offen get this worning message when use eclipse:
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.

It seems tricky to put log4j configuration files like log4j.properties or log4j.xml to the right place.  If you have multiple projects opened in your workspace, you need to put log4j configuration file to the root of classpath for every project. It should have a better way to do it. I got some idea from this post.

Here is what I did and it worked:

  1. Create a folder in the workspace (like /projects/classpath)
  2. Put log4j.properties under that folder
  3. right_click on the project and select Build Path -> Configure Build Path…
  4. Add External Class Folder… choose the folder that contains log4j configure file
  5. Click OK to finish

That’s it :)

~ by yingliang on October 29, 2009.

Leave a Reply




*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image