title: Turning on Logging in HttpClient
body: <p>How do you properly turn on Logging for Apache Commons HttpClient</p>
  <p>Right now I am doing this and getting no log messages except the one I triggered explicitly as a test:</p>
  <pre class="lang-java prettyprint-override"><code>public class HttpTest1 {
      static Log log = LogFactory.getLog(Class.class);
  
  public static void main(String[] args) throws ClientProtocolException, IOException{
          log.warn(&quot;Logging Works&quot;);
          System.setProperty(&quot;org.apache.commons.logging.Log&quot;, &quot;org.apache.commons.logging.impl.SimpleLog&quot;);
  
          System.setProperty(&quot;org.apache.commons.logging.simplelog.showdatetime&quot;, &quot;true&quot;);
          System.setProperty(&quot;org.apache.commons.logging.simplelog.log.httpclient.wire&quot;, &quot;debug&quot;);
          System.setProperty(&quot;org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient&quot;, &quot;debug&quot;);
  
          DefaultHttpClient client = new DefaultHttpClient();
  
          HttpGet method = new HttpGet(&quot;http://www.google.com&quot;);
  
          HttpResponse response = client.execute(method);
          BufferedReader rd = new BufferedReader(new InputStreamReader(
                  response.getEntity().getContent()));
  
          String line = &quot;&quot;;
          while ((line = rd.readLine()) != null) {
              System.out.println(line);
          }
      }   
  }
  </code></pre>
  <p>Output:</p>
  <pre class="lang-none prettyprint-override"><code>Feb 28, 2012 2:16:31 PM httpTest.HttpTest1 main
  WARNING: Logging Works
  &lt;!doctype html&gt;&lt;html itemscope itemtype=&quot;http://schema.org/WebPage&quot;&gt;&lt;head&gt;&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=ISO-8859-2&quot;&gt;&lt;meta itemprop=&quot;image&quot; content=&quot;/images/google_favicon_128.png&quot;&gt;&lt;title&gt;Google&lt;/title&gt;&lt;script&gt;window.google={kEI:&quot;stNMT4yfMInFtAaK_5yGDw&quot;,getEI:function(a){var d;while(a&amp;&amp;!(a.getAttribute&amp;&amp;(d=a.getAttribute(&quot;eid&quot;))))a=a.parentNode;return d||google.kEI},https:function(){return window.location.protocol==&quot;https:&quot;},kEXPI:&quot;33551,34324,34904,35055,35091,36604,36683,36934,36946,37017&quot;,kCSI:{e:&quot;33551,34324,34904,35055,35091,36604,36683,36934,36946,37017&quot;,ei:&quot;stNMT4yfMInFtAaK_5yGDw&quot;},authuser:0,
  ml:function(){},kHL:&quot;sl&quot;,time:function(){return(new Date).getTime()},log:function(a,d,f,h){var e=new Image,g=google,k=g.lc,i=g.li,m=&quot;&quot;;e.onerror=(e.onload=(e.onabort=function(){delete k[i]}));k[i]=e;if(!f&amp;&amp;d.search(&quot;&amp;ei=&quot;)==-1)m=&quot;&amp;ei=&quot;+google.getEI(h);var j=f||&quot;/gen_204?atyp=i&amp;ct=&quot;+a+&quot;&amp;cad=&quot;+d+m+&quot;&amp;zx=&quot;+google.time(),b=/^http:/i;if(b.test(j)&amp;&amp;google.https()){google.ml(new Error(&quot;GLMM&quot;),false,{src:j});
  delete k[i];return}e.src=j;g.li=i+1},lc:[],li:0,Toolbelt:{},y:{},x:function(a,d){google.y[a.id]=
  [a,d];return false}};(function(){var a=
  google.kEI;window.pp_tos={};var d=document.domain.replace(/.*?(google\..*)/,&quot;$1&quot;);function f(){var b=0;try{var c=document.cookie.match(/PP_TOS_ACK=([^;]*)/);b=c&amp;&amp;!isNaN(c[1])?c[1]:0}catch(l){e(&quot;error&quot;,&quot;read_cookie&quot;)}return b}function h(b){var c=f();if(c&gt;=0){g(++c);if(f()&gt;0&amp;&amp;!b)m()}}function e(b,c){var l=new Image;c=c?&quot;&amp;emsg=&quot;+c:&quot;&quot;;l.src=[&quot;//&quot;,d,&quot;/gen_204?atyp=i&amp;ct=pp_tos&amp;cd=&quot;,b,&quot;&amp;source=&quot;,&quot;web&quot;,&quot;&amp;ei=&quot;,a,c].join(&quot;&quot;);window.pp_tos.beacon=l}function g(b){var c=new Date((new Date).getTime()+5184000000);
  try{var l=&quot;PP_TOS_ACK=&quot;+b+&quot;; expires=&quot;+c.toGMTString()+&quot;; path=/; domain=&quot;+d;document.cookie=l}catch(n){e(&quot;error&quot;,&quot;write_cookie&quot;)}}function k(){g(-1);e(&quot;dismiss&quot;);j()}function i(){g(-1);e(&quot;tellmore&quot;);j()}function m(){var b=document.getElementById(&quot;bb_pp_tos_ack&quot;);if(b){b.style.display=&quot;&quot;;e(&quot;display&quot;)}}function j(){var b=document.getElementById(&quot;bb_pp_tos_ack&quot;);if(b)b.style.display=&quot;none&quot;}window.pp_tos.handleDismiss=k;window.pp_tos.handleLearnMore=i;window.pp_tos.checkCookie=h})();
  window.google.sn=&quot;webhp&quot;;window.google.timers={};window.google.startTick=function(a,b){window.google.timers[a]={t:{start:(new Date).getTime()},bfr:!(!b)}};window.google.tick=function(a,b,c){if(!window.google.timers[a])google.startTick(a);window.google.timers[a].t[b]=c||(new Date).getTime()};google.startTick(&quot;load&quot;,true);try{}catch(u){}
  var _gjwl=location;function _gjuc(){var e=_gjwl.href.indexOf(&quot;#&quot;);if(e&gt;=0){var a=_gjwl.href.substring(e);if(a.indexOf(&quot;&amp;q=&quot;)&gt;0||a.indexOf(&quot;#q=&quot;)&gt;=0){a=a.substring(1);if(a.indexOf(&quot;#&quot;)==-1){for(var c=0;c&lt;a.length;){var d=c;if(a.charAt(d)==&quot;&amp;&quot;)++d;var b=a.indexOf(&quot;&amp;&quot;,d);if(b==-1)b=a.length;var f=a.substring(d,b);if(f.indexOf(&quot;fp=&quot;)==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(f==&quot;cad=h&quot;)return 0;c=b}_gjwl.href=&quot;/search?&quot;+a+&quot;&amp;cad=h&quot;;return 1}}}return 0}function _gjp(){!(window._gjwl.hash&amp;&amp;
  window._gjuc())&amp;&amp;setTimeout(_gjp,500)};
  window._gjp &amp;&amp; _gjp()&lt;/script&gt;&lt;style&gt;#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}&lt;/style&gt;&lt;style id=gstyle&gt;body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.tiah{width:458px}.ds{border-bottom:solid 1px #e7e7e7;border-right:solid 1px #e7e7e7;display:-moz-inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c !important}body{background:#fff;color:black}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff!important}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px;}.lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #999 #ccc;height:30px;display:block}.pp-new-desktop,.pp-new-mobile{color:red}.ftl,#fll a{display:inline-block;margin:0 12px}.lsb{background:url(/images/srpr/nav_logo80.png) 0 -258px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}#addlang a{padding:0 3px}.gac_v div{display:none}.gac_v .gac_v2,.gac_bt{display:block!important}table.gssb_c{z-index:986  }.nbcl{background:url(/images/srpr/nav_logo80.png) no-repeat ;height:px;width:px}&lt;/style&gt;&lt;script&gt;window.rwt=function(a,f,g,l,m,h,c,n,i){try{if(a===window){a=window.event.srcElement;while(a){if(a.href)break;a=a.parentNode}}var b=encodeURIComponent||escape,d;d=a.getAttribute(&quot;href&quot;);if(c&amp;&amp;c.substring(0,6)!=&quot;&amp;sig2=&quot;)c=&quot;&amp;sig2=&quot;+c;var o=[&quot;/url?sa=t&quot;,&quot;&quot;,&quot;&amp;cd=&quot;,b(m),i?&quot;&amp;authuser=&quot;+b(i):&quot;&quot;,google.j&amp;&amp;google.j.pf?&quot;&amp;sqi=2&quot;:&quot;&quot;,&quot;&amp;ved=&quot;,b(n),&quot;&amp;url=&quot;,b(d).replace(/\+/g,&quot;%2B&quot;),&quot;&amp;ei=&quot;,&quot;stNMT4yfMInFtAaK_5yGDw&quot;,h?&quot;&amp;usg=&quot;+h:&quot;&quot;,c].join(&quot;&quot;);a.href=o;a.onmousedown=&quot;&quot;}catch(p){}return true};
  &lt;/script&gt;&lt;/head&gt;&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload=&quot;document.f&amp;&amp;document.f.q.focus();document.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'&quot; &gt;&lt;textarea id=csi style=display:none&gt;&lt;/textarea&gt;&lt;div id=mngb&gt;&lt;div id=gbar&gt;&lt;nobr&gt;&lt;b class=gb1&gt;Iskanje&lt;/b&gt; &lt;a class=gb1 href=&quot;http://www.google.si/imghp?hl=sl&amp;tab=wi&quot;&gt;Slike&lt;/a&gt; &lt;a class=gb1 href=&quot;http://maps.google.si/maps?hl=sl&amp;tab=wl&quot;&gt;Zemljevidi&lt;/a&gt; &lt;a class=gb1 href=&quot;http://translate.google.si/?hl=sl&amp;tab=wT&quot;&gt;Prevajalnik&lt;/a&gt; &lt;a class=gb1 href=&quot;http://scholar.google.si/schhp?hl=sl&amp;tab=ws&quot;&gt;U�enjak&lt;/a&gt; &lt;a class=gb1 href=&quot;http://www.google.si/blogsearch?hl=sl&amp;tab=wb&quot;&gt;Spletni dnevniki&lt;/a&gt; &lt;a class=gb1 href=&quot;https://mail.google.com/mail/?tab=wm&quot;&gt;Gmail&lt;/a&gt; &lt;/nobr&gt;&lt;/div&gt;&lt;div id=guser width=100%&gt;&lt;nobr&gt;&lt;span id=gbn class=gbi&gt;&lt;/span&gt;&lt;span id=gbf class=gbf&gt;&lt;/span&gt;&lt;span id=gbe&gt;&lt;a  href=&quot;/url?sa=p&amp;pref=ig&amp;pval=3&amp;q=http://www.google.si/ig%3Fhl%3Dsl%26source%3Diglk&amp;usg=AFQjCNHCrHelGlcr9HOQNsjP9j1ZtQCSgQ&quot; class=gb4&gt;iGoogle&lt;/a&gt; | &lt;/span&gt;&lt;a href=&quot;http://www.google.com/history/optout?hl=sl&quot; class=gb4&gt;Spletna zgodovina&lt;/a&gt; | &lt;a  href=&quot;/preferences?hl=sl&quot; class=gb4&gt;Nastavitve&lt;/a&gt; | &lt;a id=gb_70 href=&quot;https://accounts.google.com/ServiceLogin?hl=sl&amp;continue=http://www.google.si/&quot; class=gb4&gt;Prijava&lt;/a&gt;&lt;/nobr&gt;&lt;/div&gt;&lt;div class=gbh style=left:0&gt;&lt;/div&gt;&lt;div class=gbh style=right:0&gt;&lt;/div&gt;&lt;/div&gt;&lt;center&gt;&lt;br clear=all id=lgpd&gt;&lt;div id=lga&gt;&lt;div style=&quot;padding:28px 0 3px&quot;&gt;&lt;div align=left style=&quot;background:url(/intl/en_com/images/srpr/logo1w.png) no-repeat;height:110px;width:276px&quot; title=&quot;Google&quot; id=hplogo onload=&quot;window.lol&amp;&amp;lol()&quot;&gt;&lt;div nowrap style=&quot;color:#777;font-size:16px;font-weight:bold;left:214px;position:relative;top:70px&quot;&gt;Slovenija&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;form action=&quot;/search&quot; name=f&gt;&lt;table cellpadding=0 cellspacing=0&gt;&lt;tr valign=top&gt;&lt;td width=25%&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=center nowrap&gt;&lt;input name=hl type=hidden value=sl&gt;&lt;input name=source type=hidden value=hp&gt;&lt;input type=hidden name=ie value=&quot;ISO-8859-2&quot;&gt;&lt;div class=ds style=&quot;height:32px;margin:4px 0&quot;&gt;&lt;div style=&quot;position:relative;zoom:1&quot;&gt;&lt;input autocomplete=off maxlength=2048 name=q class=&quot;lst tiah&quot; title=&quot;Iskanje Google&quot; value=&quot;&quot; size=57 style=&quot;background:#fff;border:1px solid #ccc;border-bottom-color:#999;border-right-color:#999;color:#000;margin:0;padding:5px 8px 0 6px;padding-right:38px;vertical-align:top&quot;&gt;&lt;img src=&quot;/textinputassistant/tia.png&quot; width=27 height=23 alt=&quot;&quot; style=&quot;position:absolute;cursor:pointer;right:5px;top:4px;z-index:300&quot; onclick=&quot;var s=document.createElement('script');s.src='/textinputassistant/1/sl_tia.js';google.dom.append(s);&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;br style=&quot;line-height:0&quot;&gt;&lt;span class=ds &gt;&lt;span class=lsbb&gt;&lt;input name=btnG type=submit value=&quot;Iskanje Google&quot; class=lsb&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=ds&gt;&lt;span class=lsbb&gt;&lt;input name=btnI type=submit class=lsb value=&quot;Klik na sre�o&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td nowrap width=25% align=left class=&quot;fl sblc&quot;&gt;&lt;a href=&quot;/advanced_search?hl=sl&quot;&gt;Napredno iskanje&lt;/a&gt;&lt;a href=&quot;/language_tools?hl=sl&quot;&gt;Jezikovna orodja&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;input type=hidden id=gbv name=gbv value=&quot;1&quot;&gt;&lt;/form&gt;&lt;div style=&quot;font-size:83%;min-height:3.5em&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div id=res&gt;&lt;/div&gt;&lt;span id=footer&gt;&lt;center id=fctr&gt;&lt;div style=&quot;font-size:10pt&quot;&gt;&lt;div id=fll style=&quot;margin:19px auto;text-align:center&quot;&gt;&lt;a href=&quot;http://adwords.google.com/select?hl=sl&quot;&gt;Ogla�evalski programi&lt;/a&gt;&lt;a href=&quot;/intl/sl/about.html&quot;&gt;Google &amp;#8211; vse o Googlu&lt;/a&gt;&lt;a href=&quot;http://www.google.com/ncr&quot; class=&quot;gl nobr&quot;&gt;Google.com in English&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;color:#767676;font-size:8pt&quot;&gt;&amp;copy; 2012&lt;/p&gt;&lt;/center&gt;&lt;/span&gt; &lt;/center&gt;&lt;div id=xjsd&gt;&lt;/div&gt;&lt;div id=xjsi&gt;&lt;script&gt;if(google.y)google.y.first=[];google.dlj=function(b){window.setTimeout(function(){var a=document.createElement(&quot;script&quot;);a.src=b;document.getElementById(&quot;xjsd&quot;).appendChild(a)},0)};
  if(google.y)google.y.first=[];if(!google.xjs){google.dstr=[];google.rein=[];if(google.timers&amp;&amp;google.timers.load.t){google.timers.load.t.xjsls=new Date().getTime();}google.dlj('/extern_js/f/CgJzbBICc2kgASswRTgALCswWjgALCswDjgALCswFzgALCswPDgALCswUTgALCswCjgAmgICaGUsKzCYATgALCswFjgALCswGTgALCswQTgALCswTTgALCswTjgALCswVDgALCswaTgALCswkAE4ACwrMJIBOAAsKzDVATgALCsw2AE4ACwrMBg4ACwrMCY4ACyAAlCQAmc/KdS-qUb5nqw.js');google.xjs=1}google.neegg=1;google.mc=[];google.mc=google.mc.concat([[69,{}],[14,{}],[60,{}],[23,{}],[81,{}],[10,{&quot;client&quot;:&quot;hp&quot;,&quot;dh&quot;:true,&quot;ds&quot;:&quot;&quot;,&quot;fl&quot;:true,&quot;host&quot;:&quot;google.si&quot;,&quot;jsonp&quot;:true,&quot;msgs&quot;:{&quot;lcky&quot;:&quot;Klik na sre�o&quot;,&quot;lml&quot;:&quot;Ve� o tem&quot;,&quot;psrc&quot;:&quot;To iskanje je bilo odstranjeno iz \u003Ca href=\&quot;/history\&quot;\u003Ezgodovine iskanja\u003C/a\u003E&quot;,&quot;psrl&quot;:&quot;Odstrani&quot;,&quot;srch&quot;:&quot;Iskanje Google&quot;},&quot;ovr&quot;:{&quot;fm&quot;:1,&quot;o&quot;:1,&quot;pf&quot;:1,&quot;ps&quot;:1,&quot;sn&quot;:1,&quot;sw&quot;:1},&quot;pq&quot;:&quot;&quot;,&quot;scd&quot;:10,&quot;sce&quot;:5}],[152,{}],[65,{}],[213,{&quot;pberr&quot;:&quot;\u003Cfont color=red\u003ENapaka:\u003C/font\u003E Stre�nik ni mogel dokon�ati va�e zahteve. Poskusite znova �ez 30 sekund.&quot;}],[78,{}],[25,{&quot;g&quot;:8,&quot;k&quot;:false,&quot;m&quot;:{&quot;app&quot;:true,&quot;bks&quot;:true,&quot;blg&quot;:true,&quot;dsc&quot;:true,&quot;evn&quot;:true,&quot;fin&quot;:true,&quot;flm&quot;:true,&quot;frm&quot;:true,&quot;isch&quot;:true,&quot;klg&quot;:true,&quot;mbl&quot;:true,&quot;nws&quot;:true,&quot;plcs&quot;:true,&quot;ppl&quot;:true,&quot;prc&quot;:true,&quot;pts&quot;:true,&quot;rcp&quot;:true,&quot;shop&quot;:true,&quot;vid&quot;:true},&quot;t&quot;:null}],[216,{}],[105,{}],[22,{&quot;db&quot;:false,&quot;m_errors&quot;:{&quot;32&quot;:&quot;�al ni drugih rezultatov.&quot;,&quot;default&quot;:&quot;\u003Cfont color=red\u003ENapaka:\u003C/font\u003E Stre�nik ni mogel dokon�ati va�e zahteve. Poskusite znova �ez 30 sekund.&quot;},&quot;m_tip&quot;:&quot;Kliknite za ve� informacij&quot;,&quot;nlpm&quot;:&quot;-153px -84px&quot;,&quot;nlpp&quot;:&quot;-153px -70px&quot;,&quot;utp&quot;:false}],[77,{}],[146,{}],[144,{}],[84,{}],[24,{}],[38,{}]]);google.y.first.push(function(){if(google.med){google.med('init');google.initHistory();google.med('history');}google.History&amp;&amp;google.History.initialize('/')});if(google.j&amp;&amp;google.j.en&amp;&amp;google.j.xi){window.setTimeout(google.j.xi,0);}&lt;/script&gt;&lt;/div&gt;&lt;script&gt;(function(){
  var b,d,e,f;function g(a,c){if(a.removeEventListener){a.removeEventListener(&quot;load&quot;,c,false);a.removeEventListener(&quot;error&quot;,c,false)}else{a.detachEvent(&quot;onload&quot;,c);a.detachEvent(&quot;onerror&quot;,c)}}function h(a){f=(new Date).getTime();++d;a=a||window.event;var c=a.target||a.srcElement;g(c,h)}var i=document.getElementsByTagName(&quot;img&quot;);b=i.length;d=0;for(var j=0,k;j&lt;b;++j){k=i[j];if(k.complete||typeof k.src!=&quot;string&quot;||!k.src)++d;else if(k.addEventListener){k.addEventListener(&quot;load&quot;,h,false);k.addEventListener(&quot;error&quot;,
  h,false)}else{k.attachEvent(&quot;onload&quot;,h);k.attachEvent(&quot;onerror&quot;,h)}}e=b-d;function l(){if(!google.timers.load.t)return;google.timers.load.t.ol=(new Date).getTime();google.timers.load.t.iml=f;google.kCSI.imc=d;google.kCSI.imn=b;google.kCSI.imp=e;if(google.stt!==undefined)google.kCSI.stt=google.stt;google.timers.load.t.xjs&amp;&amp;google.report&amp;&amp;google.report(google.timers.load,google.kCSI)}if(window.addEventListener)window.addEventListener(&quot;load&quot;,
  l,false);else if(window.attachEvent)window.attachEvent(&quot;onload&quot;,l);google.timers.load.t.prt=(f=(new Date).getTime());
  })();
  &lt;/script&gt;
  </code></pre>
  <p>I am using Eclipse.</p>