title: How to disable log4j logging in Http Client 4.1 to log to FileAppender
body: <p>Here is my log4j configuration for a HTTP client:</p>
  
  <pre><code>log4j.appender.HTTPCLIENT_APPDR=com.xxx.log.FileAppender
  log4j.appender.HTTPCLIENT_APPDR.File=${user.dir}/log/access.log
  log4j.appender.HTTPCLIENT_APPDR.layout=org.apache.log4j.PatternLayout
  log4j.appender.HTTPCLIENT_APPDR_APPDR.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss SSS}ms %-5p [%t] - %m%n
  log4j.appender.HTTPCLIENT_APPDR.MaxFileSize=20000KB
  log4j.appender.HTTPCLIENT_APPDR.MaxBackupIndex=30
  log4j.logger.org.apache.http=DEBUG,HTTPCLIENT_APPDR
  </code></pre>
  
  <p>I would like it to turn off the <code>httpclient</code> logging from the CODE depending on the environment I am in (I know how to disable it from the log4j.properties).</p>
  
  <p>I tried inserting these lines:</p>
  
  <pre><code>+    System.setProperty("log4j.logger.org.apache.http", "ERROR"); 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>+    Logger.getLogger("log4j.logger.org.apache.http").setLevel(Level.off)
  </code></pre>
  
  <p>in the start of my application but it does not work.<code></p>
  
  <ol>
  <li>Can I access the log4j properties from the System class?</li>
  <li>When I look at the <code>Logger.getLogger("log4j.logger.org.apache.http")</code> the level is null? Should it not be DEBUG?</li>
  </ol>
  
  <p>What worked finally,</p>
  
  <pre>Logger.getLogger("org.apache.http").setLevel(org.apache.log4j.Level.OFF);
  </code></pre>
  
  <p>I was not using the right key.</p>
  
  <p>Regards, <br></p>