title: Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER>
body: <p>I wish to write custom appender on the basis of <a href="http://logback.qos.ch/apidocs/ch/qos/logback/core/OutputStreamAppender.html" rel="nofollow"><code>OutputStreamAppender</code></a>. I wrote the following class</p>
  
  <pre><code>package tests;
  
  import java.io.IOException;
  import java.io.OutputStream;
  
  import ch.qos.logback.core.OutputStreamAppender;
  
  public class MyAppender&lt;E&gt; extends OutputStreamAppender&lt;E&gt; {
      public MyAppender() {
  
          System.out.println("MyAppender created");
  
          setOutputStream(new OutputStream() {
  
              @Override
              public void write(int b) throws IOException {
                  throw new UnsupportedOperationException();
              }
          });
      }
  }
  </code></pre>
  
  <p>then I wrote the following runner:</p>
  
  <pre><code>package tests;
  
  import org.slf4j.LoggerFactory;
  
  import ch.qos.logback.classic.Logger;
  
  public class Runner {
  
      private static final Logger log = (Logger) LoggerFactory.getLogger(Runner.class);
  
  
      public static void main(String[] args) {
  
          //log.addAppender(new MyAppender&lt;ILoggingEvent&gt;());
  
          log.info("Hello world");
      }
  }
  </code></pre>
  
  <p>finally I wrote the following <code>logback.xml</code>:</p>
  
  <pre><code>&lt;configuration&gt;
  
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="MYAPPENDER" class="tests.MyAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
  
  
      &lt;root level="debug"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and got the following output:</p>
  
  <pre><code>MyAppender created
  LOGBACK: No context given for tests.MyAppender[null]
  20:45:29.957 [main] INFO  Runner - Hello world
  </code></pre>
  
  <p>it indicates that appender is instantiated. But absence of exceptions mean it is never called.</p>
  
  <p>Probably this is related with error message which I don't understand: "LOGBACK: No context given for tests.MyAppender[null]"</p>
  
  <p>What is it mean and how to fix?</p>