Aim:
I picked up a Java project that used a lot of System.out.println statements. As an exercise, I wanted to replace them with apache's log4j.
First things:
Download log4j, and include it in your Eclipse project. Follow the instructions here:
Next things:These instructions do not work out of the box, I kept getting an error:
- you must un-comment the line log4j.rootLogger in the log4j.properties
- you must include -Dlog4j.configuration="file:./log4j.properties" in VM Arguments
That should start pumping out logs onto the console view of Eclipse and also in the log file.
I picked up a Java project that used a lot of System.out.println statements. As an exercise, I wanted to replace them with apache's log4j.
First things:
Download log4j, and include it in your Eclipse project. Follow the instructions here:
Next things:These instructions do not work out of the box, I kept getting an error:
log4j:WARN No appenders could be found for logger (com.xxx.xxx.xx.xxx).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
After a bit of digging around, I found a bunch of combinations to make it work:- you must un-comment the line log4j.rootLogger in the log4j.properties
- you must include -Dlog4j.configuration="file:./log4j.properties" in VM Arguments
That should start pumping out logs onto the console view of Eclipse and also in the log file.
No comments:
Post a Comment