title: Different log files using Logback
body: <p>I would like to log different log levels to different files , In addition to this I would like to have the default consoleAppender as well for each log level.</p>
  
  <p>So the output should be different log level files :</p>
  
  <ol>
  <li>Info level file</li>
  <li>Warn level file</li>
  <li>Error level file</li>
  <li>Console should also remain enabled all the time.</li>
  </ol>
  
  <p></p>
  
  <pre><code>  &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;!-- encoders are assigned the type
           ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --&gt;
      &lt;encoder&gt;
        &lt;charset&gt;UTF-8&lt;/charset&gt;
        &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{35}) - %msg %n&lt;/pattern&gt;
      &lt;/encoder&gt;
    &lt;/appender&gt;
  
      &lt;!-- Logging settings for the info logs --&gt;
    &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
      &lt;filter class="ch.qos.logback.classic.filter.LevelFilter"&gt;
        &lt;level&gt;INFO&lt;/level&gt;
        &lt;onMatch&gt;ACCEPT&lt;/onMatch&gt;
      &lt;/filter&gt; 
      &lt;file&gt;logs\logFile.html&lt;/file&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
        &lt;!-- daily rollover --&gt;
        &lt;fileNamePattern&gt;logs\logFile.%d{yyyy-MM-dd}.%i.html&lt;/fileNamePattern&gt;
        &lt;timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
            &lt;!-- or whenever the file size reaches 50MB --&gt;
          &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
        &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
        &lt;!-- keep 60 days' worth of history --&gt;
        &lt;maxHistory&gt;60&lt;/maxHistory&gt;
      &lt;/rollingPolicy&gt;
      &lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"&gt;
        &lt;charset&gt;UTF-8&lt;/charset&gt;
        &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"&gt;
          &lt;pattern&gt;%d{HH:mm:ss.SSS}%thread%level%logger%line%msg&lt;/pattern&gt;
        &lt;/layout&gt;         
      &lt;/encoder&gt;
    &lt;/appender&gt;
  
    &lt;!-- Logging settings for the error logs --&gt;
    &lt;appender name="FILEERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
    &lt;filter class="ch.qos.logback.classic.filter.LevelFilter"&gt;
        &lt;level&gt;ERROR&lt;/level&gt;
        &lt;onMatch&gt;ACCEPT&lt;/onMatch&gt;
      &lt;/filter&gt; 
      &lt;file&gt;logs\logFileError.html&lt;/file&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
        &lt;!-- daily rollover --&gt;
        &lt;fileNamePattern&gt;logs\logFileError.%d{yyyy-MM-dd}.%i.html&lt;/fileNamePattern&gt;
        &lt;timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
            &lt;!-- or whenever the file size reaches 50MB --&gt;
          &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
        &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
        &lt;!-- keep 60 days' worth of history --&gt;
        &lt;maxHistory&gt;60&lt;/maxHistory&gt;
      &lt;/rollingPolicy&gt;
      &lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"&gt;
        &lt;charset&gt;UTF-8&lt;/charset&gt;
        &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"&gt;
          &lt;pattern&gt;%d{HH:mm:ss.SSS}%thread%level%logger%line%msg&lt;/pattern&gt;
        &lt;/layout&gt;         
      &lt;/encoder&gt;
    &lt;/appender&gt;
  
    &lt;!-- Logging settings for the warn logs --&gt;
    &lt;appender name="FILEWARN" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
    &lt;filter class="ch.qos.logback.classic.filter.LevelFilter"&gt;
        &lt;level&gt;WARN&lt;/level&gt;
        &lt;onMatch&gt;ACCEPT&lt;/onMatch&gt;
      &lt;/filter&gt; 
      &lt;file&gt;logs\logFileWarn.html&lt;/file&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
        &lt;!-- daily rollover --&gt;
        &lt;fileNamePattern&gt;logs\logFileWarn.%d{yyyy-MM-dd}.%i.html&lt;/fileNamePattern&gt;
        &lt;timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
            &lt;!-- or whenever the file size reaches 50MB --&gt;
          &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
        &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
        &lt;!-- keep 60 days' worth of history --&gt;
        &lt;maxHistory&gt;60&lt;/maxHistory&gt;
      &lt;/rollingPolicy&gt;
      &lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"&gt;
        &lt;charset&gt;UTF-8&lt;/charset&gt;
        &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"&gt;
          &lt;pattern&gt;%d{HH:mm:ss.SSS}%thread%level%logger%line%msg&lt;/pattern&gt;
        &lt;/layout&gt;         
      &lt;/encoder&gt;
    &lt;/appender&gt;   
  
    &lt;root level="info"&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
      &lt;appender-ref ref="FILE" /&gt;     
    &lt;/root&gt;
  
    &lt;root level="error"&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
      &lt;appender-ref ref="FILEERROR" /&gt;     
    &lt;/root&gt;
  
    &lt;root level="warn"&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
      &lt;appender-ref ref="FILEWARN" /&gt;     
    &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The problem here is it writes each type of level in all files.</p>