KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How do you properly turn on Logging for Apache Commons HttpClient Right now I am doing this and getting no log messages except the one I triggered explicitly as a test: public class HttpTest1 { static Log log = LogFactory.getLog(Class.class); public static void main(String[] args) throws ClientProtocolException, IOException{ log.warn("Logging Works"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); DefaultHttpClient client = new DefaultHttpClient(); HttpGet method = new HttpGet("http://www.google.com"); HttpResponse response = client.execute(method); BufferedReader rd = new BufferedReader(new InputStreamReader( response.getEntity().getContent())); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); } } } Output: Feb 28, 2012 2:16:31 PM httpTest.HttpTest1 main WARNING: Logging Works <!doctype html><html itemscope itemtype="http://schema.org/WebPage"><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-2"><meta itemprop="image" content="/images/google_favicon_128.png"><title>Google</title><script>window.google={kEI:"stNMT4yfMInFtAaK_5yGDw",getEI:function(a){var d;while(a&&!(a.getAttribute&&(d=a.g
Tags (comma-separated)
Save Edits
Cancel