I want to put on logging in httpclient with log4j. Doing this, I added a file commons-logging.properties with the content org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger. Then I added a file log4j.properties with the following content provided by httpclient documentation as a logging example:
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.org.apache.http=DEBUG
log4j.logger.org.apache.http.wire=ERROR
Both files reside in the classpath. I put the following parameters
-Dlog4j.configuration=log4j.properties
-Dlog4j.debug
However, when I run my programm which executes http requests with the httpclient I do not see any logging output. The latter parameter should make the output of log4j verbose in that sense, that it displays several things e.g. the used properties files. This is not displayed at all. What I tried as wel is to read out the logger programmaciatally with
Logger.getLogger("log4j.logger.org.apache.http.wire").getLevel().toString()
this throws an null pointer exception.
Additionally I read
LogManager.getCurrentLoggers().hasMoreElements()
this is always false.
It seems like log4j is not "activated" for httpclient. Can anyone help me here what I could do in order to turn the logging on?
(Yes, I already read related topics here at stackoverflow)
Thank you very much
Felix