title: Configure logback to defer to Java configuration aka Plain Java Configuration of Logback
body: <p>I just do not like Logback's XML or Groovy configuration and would prefer to do the configuration in Java (this is also because I'm going to change the configuration at runtime at various times after initialization).</p>
  
  <p>It seems the only way to do Java configuration of Logback is to have some sort of initialization that <a href="https://github.com/dropwizard/dropwizard/blob/master/dropwizard-logging/src/main/java/io/dropwizard/logging/LoggingFactory.java" rel="noreferrer">hijacks the root appender</a> or to have custom system properties that tell logback to not use the default configuration (which is rather annoying for unit tests and deployment).</p>
  
  <p>What I would much rather prefer is something like a <code>logback.xml</code> :</p>
  
  <pre><code>&lt;configuration javaConfig="com.myco.LogBackConfig" /&gt; 
  </code></pre>
  
  <p>Where LogbackConfig either has some established static method that logback calls or it just re-instantiates a Java bean.</p>
  
  <p>That is I want a default classpath resource that will tell logback to use Java instead of groovy/xml. Basically I want something akin to the <a href="http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html" rel="noreferrer">Java ServiceLoader</a> for logback config.</p>
  
  <p>Perhaps there is a way to do this in Logback that I am missing?</p>
  
  <p><strong>UPDATE:</strong>
  Apparently <a href="http://logging.apache.org/log4j/2.x/manual/extending.html" rel="noreferrer">Log4j2 (the new log4j) does exactly what I want</a> and is very similar to the Java ServiceLoader.</p>