title: Add tags to logback configuration
body: <p>I am trying to write custom appenders which have a special configuration and I would need to make corresponding tags for their xml configuration.  It is clear from logback manual how this should be done: by adding new rules to the configurator as explained here: <a href="http://logback.qos.ch/manual/onJoran.html" rel="nofollow">http://logback.qos.ch/manual/onJoran.html</a></p>
  
  <p>My problem is how to add this rule when the configurator is not created directly, but when it's created by the slf4j binding. When you first access a slf4j-api a <code>LoggerFactory</code>, slf4j-api will look for an available binding in the classpath. If you correctly have <code>logback-classic</code> the binding will be found, it's the class <code>StaticLoggerBinder</code>. Its initialization shows </p>
  
  <pre><code>  try {
        try {
          new ContextInitializer(defaultLoggerContext).autoConfig();
        } catch (JoranException je) {
          Util.report("Failed to auto configure default logger context", je);
        }
        // logback-292
        if(!StatusUtil.contextHasStatusListener(defaultLoggerContext)) {
          StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
        }
        contextSelectorBinder.init(defaultLoggerContext, KEY);
        initialized = true;
      } catch (Throwable t) {
        // we should never get here
        Util.report("Failed to instantiate [" + LoggerContext.class.getName()
            + "]", t);
      }
    }
  </code></pre>
  
  <p>If we look inside the <code>ContextInitializer.autoconfig()</code> we see that if an initialization file is available, it delegates the work to</p>
  
  <pre><code>public void configureByResource(URL url) throws JoranException {
      if (url == null) {
        throw new IllegalArgumentException("URL argument cannot be null");
      }
      if (url.toString().endsWith("groovy")) {
        if (EnvUtil.isGroovyAvailable()) {
          // avoid directly referring to GafferConfigurator so as to avoid
          // loading  groovy.lang.GroovyObject . See also http://jira.qos.ch/browse/LBCLASSIC-214
          GafferUtil.runGafferConfiguratorOn(loggerContext, this, url);
        } else {
          StatusManager sm = loggerContext.getStatusManager();
          sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.",
                  loggerContext));
        }
      }
      if (url.toString().endsWith("xml")) {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(loggerContext);
        configurator.doConfigure(url);
      }
    }
  </code></pre>
  
  <p>As you see, there is no way to add rules to the configurator used to parse the logback.xml when it is created. The only solution I have found is the following. First, I put a new rule in all my logback configurations where I need my custom tags and then inside this rule code, I add other rules.</p>
  
  <pre><code>  &lt;newRule pattern="*/appender/asynclogger" actionClass="com.logentries.logback.joran.AsyncLoggerAction"/&gt;
  
  
      &lt;appender name="LE" class="com.logentries.logback.LogentriesAppender"&gt;
          &lt;asynclogger&gt;
              &lt;logentries-httpput ssl="false" account="myAccount" key="myKey"/&gt;
              &lt;ignore-exceptions/&gt;
          &lt;/asynclogger&gt;
          &lt;facility&gt;USER&lt;/facility&gt;
          &lt;layout&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n&lt;/pattern&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
  </code></pre>
  
  <p>I have the feeling I am doing this in a sub-optimal way, is there a better solution ?</p>