I’m trying out log4j in a simple test app. I create a new Java project in eclipse and add the log4j JAR (v1.2.16) to my build path. I then create a simple class that prints Hello World. Then I use the log4j Logger class to log a info message. When I run the app, I see the log message, using what I assume is the default appender and layout. Great. What I’m having trouble with is adding my own configuration. This is what I’ve done:
Created a log4j.properties file with a custom appender and log level and placed it into the src folder (which upon compilation gets copied to the bin folder). Run the app – no change.
I try adding PropertyConfigurator.configure("log4j.properties"). Run the app – no change. No errors, but no change.
What do I have to do to get log4j to load my configuration file?
Argh. I discovered the problem was that eclipse had imported the wrong
Loggerclass. It had imported java.util.logging.Logger which of course has it’s own configuration that is different from log4j. Oh well, hope somebody else does this and gets it solved by reading this question.