title: Logback Configuration: Two appenders, logging based on package
body: <p>I'm trying to configure logback so that certain packages are logged differently depending on the appender.  I have a <code>ConsoleAppender</code> and a <code>RollingFileAppender</code>.  I want <code>TRACE</code> level logging for the <code>ConsoleAppender</code> and I want only two packages logged to the <code>RollingFileAppender</code>.  What ends up happening is my <code>ConsoleAppender</code> and <code>RollingFileAppender</code> behave exactly the same.</p>
  
  <p>Here is my <code>logback.xml</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE configuration&gt;
  &lt;configuration&gt;
      &lt;property resource="logback.properties" /&gt;
  
      &lt;appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;.%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="dailyRollingFileAppender"
          class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
  
          &lt;file&gt;${logback.dir}${logback.filename}.log&lt;/file&gt;
  
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
              &lt;!-- daily rollover --&gt;
              &lt;fileNamePattern&gt;${logback.dir}${logback.filename}.%d{yyyy-MM-dd}.log&lt;/fileNamePattern&gt;
  
              &lt;!-- keep 90 days' worth of history --&gt;
              &lt;maxHistory&gt;90&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;encoder&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg %n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;logger name="org.springframework" level="INFO"&gt;
          &lt;appender-ref ref="dailyRollingFileAppender" /&gt;
      &lt;/logger&gt;
      &lt;logger name="x.y" level="DEBUG"&gt;
          &lt;appender-ref ref="dailyRollingFileAppender" /&gt;
      &lt;/logger&gt;
  
      &lt;root&gt;
          &lt;level value="TRACE" /&gt;
          &lt;appender-ref ref="consoleAppender" /&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>