hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tommmmmm <tommm...@gmail.com>
Subject Re: How to use logging abilities of HttpClient?
Date Wed, 11 Apr 2012 09:44:41 GMT
2 relevant things:
1) Output of:

System.out.println(httpClient.getClass().getClassLoader().getResource("commons-logging.properties"));

System.out.println(httpClient.getClass().getClassLoader().getResource("log4.jeroen"));

System.out.println(httpClient.getClass().getClassLoader().getResource("log4j.properties"));

System.out.println(httpClient.getClass().getClassLoader().getResource("org/apache/log4j/Logger.class"));

System.out.println(httpClient.getClass().getClassLoader().getResource("org/apache/commons/logging/Log.class"));
is:
null
null
null
jar:file:/home/min/ucng/javaLibs/apache-log4j-1.2.16/log4j-1.2.16.jar!/org/apache/log4j/Logger.class
jar:file:/home/min/ucng/javaLibs/commons-logging-1.1.1/commons-logging-1.1.1.jar!/org/apache/commons/logging/Log.class

2) I created a StupidClass in some OTHER package:
public class StupidClass {
    private static Logger logger = Logger.getLogger("tests.StupidClass");
    public void logSmth() {
        logger.debug("stupid class debug logger test");
    }
}

Then added this to config file:
log4j.logger.stupidClass=DEBUG

Then did this in my main class:
        StupidClass c = new StupidClass();
        c.logSmth();

And I got this output:
DEBUG [tests.StupidClass] stupid class debug logger test

And that ladies and gentleman is an ultimate proof that it's HttpClient's
fault that logging doesn't work at all. Because from application's point of
view, the class StupidClass and HttpClient are the same <=> a class outside
a package. And log4j CAN communicate with class outside of package very
well and very easily - it is HttpClient that is delibaretly IGNORING those
calls from log4j. So fixing the logging issues was a dead end from the
beginning - because what must be fixed is HttpClient itself and not logging
thingies.

So the question is: why HttpClient ignores log4j ?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message