Apache commons logging, log4j, “WARN No appenders could be found for logger” and “WARN Please initialize the log4j system properly”

by

Using Apache’s HTTP client implementation in Java I’ve been seeing this:

log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.

The sensible fix appears to be:

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");

(As all J2SE versions since 2002 (!) have had a workable logger built in; this would seem like a more sensible default. If it was a developer’s desire to benefit not merely from the standardised API but also from the common implementation then, presumably, using Log4J directly would be what they’d do…)

Also useful to remove unnecessary chatter:

Logger.getAnonymousLogger().getParent().setLevel(Level.WARNING);
Advertisements

2 Responses to “Apache commons logging, log4j, “WARN No appenders could be found for logger” and “WARN Please initialize the log4j system properly””

  1. Surendra Paluri Says:

    I searched everywhere and found your code working. Thanks

  2. NGOWDA Says:

    thanks it is working for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: