Saher Ahwal
Saher Ahwal

Reputation: 9237

log4j: Warn No appenders could be found

I am receiving this warning which interrupts the running of my web application.

    log4j:WARN No appenders could be found for logger (smslib).
    log4j:WARN Please initialize the log4j system properly.

I have the log4j JAR file in my library. I have deleted it and added it again ... this warning keeps showing up.

Thanks for your time,

Upvotes: 0

Views: 2060

Answers (2)

Alex Arnon
Alex Arnon

Reputation: 113

For small stand-alone programs and unit tests, I use BasicConfigurator.

To init:

BasicConfigurator.configure();

To cleanup:

BasicConfigurator.resetConfiguration();

If you're using JUnit, you should generally remember to place the cleanup code in your @After/tearDown(), since the configure() method adds a console appender if log4j had already been initialized.

Upvotes: 5

Jon Skeet
Jon Skeet

Reputation: 1500055

Well log4j is clearly being found, otherwise it couldn't be warning you like this!

What's more likely to be missing is a log4j configuration. There are lots of ways you can do this in a web application - how are you trying?

Upvotes: 2

Related Questions