httpclient uses a community entry as described here: http://hc.apache.org/httpcomponents-client-4.2.x/logging.html
In this way, he delegates access to your logging system. To configure the logging of HTTP requests, you need to use the registration framework API. For example, if you use JDK logging, something like this should work:
java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(Level.ALL)
Each logging environment will have its own API.
To use the built-in SimpleLog implementation, packaged using public record keeping, you can do something like this:
System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.defaultlog","trace"); DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://www.google.com"); client.execute(request);
Running this code should print a lot of log output to the console (syserr).
Note that simplelog is not really a good choice for a production logging structure. You really should use something like log4j.
Barak
source share