title: Apache Storm: Custom logging
body: <p>I want to modify Storms logback/cluster.xml so that it will write to different files depending on an ID. </p>
  
  <p>Looking at the info I need to change the cluster.xml and add a Sifting Appender. Reference <a href="http://logback.qos.ch/manual/appenders.html#SiftingAppender" rel="nofollow">HERE</a> </p>
  
  <p><strong>Main Question</strong>
  Is this the best/correct method? 
  An example? </p>
  
  <p>I will need to add in:</p>
  
  <pre><code> MDC.put("userid", "Alice");
   logger.debug("Alice says hello");
  </code></pre>
  
  <p><strong>Example Help</strong></p>
  
  <p>For the example I cannot seem to get it writing to a file. I use a default logback.xml in the classpath. I do not pass in the arg and load the config as I assume it will be found in the classpath. But then no file is written? </p>
  
  <pre><code>&lt;configuration&gt;
  
  &lt;appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"&gt;
      &lt;!-- in the absence of the class attribute, it is assumed that the desired 
          discriminator type is ch.qos.logback.classic.sift.MDCBasedDiscriminator --&gt;
      &lt;discriminator&gt;
          &lt;key&gt;userid&lt;/key&gt;
          &lt;defaultValue&gt;unknown&lt;/defaultValue&gt;
      &lt;/discriminator&gt;
      &lt;sift&gt;
          &lt;appender name="FILE-${userid}" class="ch.qos.logback.core.FileAppender"&gt;
              &lt;file&gt;$/Users/Stuart/Desktop/main.log&lt;/file&gt;
              &lt;append&gt;false&lt;/append&gt;
              &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
                  &lt;pattern&gt;%d [%thread] %level %mdc %logger{35} - %msg%n&lt;/pattern&gt;
              &lt;/layout&gt;
          &lt;/appender&gt;
      &lt;/sift&gt;
  &lt;/appender&gt;
  
  &lt;root level="DEBUG"&gt;
      &lt;appender-ref ref="SIFT" /&gt;
  &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>