title: How to programmatically setup slf4j logger with SLF4JBridgeHandler
body: <p>I'm trying to setup slf4j to intercept all logging statements and then programmatically add the handlers based on certain conditions. My code is:</p>
  
  <pre><code>private void init()
  {
      SLF4JBridgeHandler.removeHandlersForRootLogger();
      SLF4JBridgeHandler.install();
  
      if(condition1)
          appendHandler(console, Level.DEBUG);
      if(condition2)
          appendHandler(logfile1, Level.INFO);
      ...
  }
  </code></pre>
  
  <p>How do I write the code for <code>appendHandler</code> method? I've just spent a few hours trying to read through documentation and cannot find a solution. There are lots of references on how to do it in configuration files but not in code. </p>
  
  <p>Also am I correct in that this code intercepts all logging statements for all the different logging frameworks?</p>