title: How to log INFO into one file and ERROR into another file using log4j in spring boot.
body: <p>I have tried <strong>application.properties</strong> </p>
  
  <pre><code>logging.level.org.springframework.security= DEBUG
  logging.level.org.hibernate= DEBUG
  logging.file=D:/LogDemo/DemoDebug.log
  
  logging.level.root= WARN
  logging.file=D:/LogDemo/DemoWarn.log
  </code></pre>
  
  <hr>
  
  <p><em>But log is appending only in the last file ( Here, demoinfo.log)</em>
  If ERROR level is the last one , only log will appending only in the specified file.</p>
  
  <p>And I have tried log4j2.xml also</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="WARN"&gt;
    &lt;appender name="DEBUG-LOG-FILE" class="org.apache.log4j.rolling.RollingFileAppender"&gt; 
          &lt;param name="file" value="D:/LogDemo/Debug.log"/&gt; 
          &lt;param name="append" value="true" /&gt; 
      &lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&gt; 
        &lt;!-- daily rollover --&gt;
        &lt;param name="FileNamePattern" value="Debug.%d{yyyy-MM-dd}.log.zip"/&gt; 
        &lt;!-- keep 30 days' worth of history 
        &lt;param name="MaxBackupIndex" value="30"/&gt; --&gt;
      &lt;/rollingPolicy&gt; 
      &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
          &lt;!--&lt;Pattern&gt;%d{HH:mm:ss.SSS} %-5level [%thread] %logger{35} - %msg%n&lt;/Pattern&gt;--&gt;
          &lt;param name="ConversionPattern" value="%d %-5p %logger{35} - %m%n"/&gt; 
      &lt;/layout&gt; 
      &lt;filter class="org.apache.log4j.varia.LevelMatchFilter"&gt; 
          &lt;param name="LevelToMatch" value="debug"/&gt; 
          &lt;param name="AcceptOnMatch" value="true"/&gt; 
          &lt;/filter&gt;  
          &lt;filter class="org.apache.log4j.varia.DenyAllFilter"/&gt; 
    &lt;/appender&gt; 
  
    &lt;appender name="ERROR-LOG-FILE" class="org.apache.log4j.rolling.RollingFileAppender"&gt; 
          &lt;param name="file" value="D:/LogDemo/Error.log"/&gt; 
          &lt;param name="append" value="true" /&gt; 
      &lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&gt; 
        &lt;!-- daily rollover --&gt;
        &lt;param name="FileNamePattern" value="Error.%d{yyyy-MM-dd}.log.zip"/&gt; 
        &lt;!-- keep 30 days' worth of history 
        &lt;param name="MaxBackupIndex" value="30"/&gt; --&gt;
      &lt;/rollingPolicy&gt; 
      &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
        &lt;!--&lt;Pattern&gt;%d{HH:mm:ss.SSS} %-5level [%thread] %logger{35} - %msg%n&lt;/Pattern&gt;--&gt;
        &lt;param name="ConversionPattern" value="%d %-5p %logger{35} - %m%n"/&gt; 
      &lt;/layout&gt; 
          &lt;filter class="org.apache.log4j.varia.LevelMatchFilter"&gt; 
                  &lt;param name="LevelToMatch" value="error" /&gt; 
                  &lt;param name="AcceptOnMatch" value="true"/&gt; 
          &lt;/filter&gt; 
          &lt;filter class="org.apache.log4j.varia.DenyAllFilter" /&gt; 
    &lt;/appender&gt; 
  
    &lt;appender name="INFO-LOG-FILE" class="org.apache.log4j.rolling.RollingFileAppender"&gt; 
          &lt;param name="file" value="D:/LogDemo/Info.log"/&gt; 
          &lt;param name="append" value="true" /&gt; 
      &lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&gt; 
        &lt;!-- daily rollover --&gt;
        &lt;param name="FileNamePattern" value="Info.%d{yyyy-MM-dd}.log.zip"/&gt; 
        &lt;!-- keep 30 days' worth of history 
        &lt;param name="MaxBackupIndex" value="30"/&gt; --&gt;
      &lt;/rollingPolicy&gt; 
      &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
        &lt;!--&lt;Pattern&gt;%d{HH:mm:ss.SSS} %-5level [%thread] %logger{35} - %msg%n&lt;/Pattern&gt;--&gt;
        &lt;param name="ConversionPattern" value="%d %-5p %logger{35} - %m%n"/&gt; 
      &lt;/layout&gt; 
          &lt;filter class="org.apache.log4j.varia.LevelMatchFilter"&gt; 
                  &lt;param name="LevelToMatch" value="info" /&gt; 
                  &lt;param name="AcceptOnMatch" value="true"/&gt; 
          &lt;/filter&gt; 
          &lt;filter class="org.apache.log4j.varia.DenyAllFilter" /&gt; 
    &lt;/appender&gt; 
  
    &lt;appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"&gt; 
      &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
        &lt;param name="ConversionPattern" value="%d %-5p %logger{35} - %m%n"/&gt; 
      &lt;/layout&gt; 
          &lt;filter class="org.apache.log4j.varia.LevelMatchFilter"&gt; 
                  &lt;param name="LevelToMatch" value="debug" /&gt; 
                  &lt;param name="AcceptOnMatch" value="true"/&gt; 
          &lt;/filter&gt; 
          &lt;filter class="org.apache.log4j.varia.DenyAllFilter" /&gt; 
    &lt;/appender&gt; 
  
    &lt;root&gt; 
      &lt;level value="debug" /&gt; 
      &lt;appender-ref ref="DEBUG-LOG-FILE" /&gt; 
      &lt;appender-ref ref="ERROR-LOG-FILE" /&gt; 
      &lt;appender-ref ref="INFO-LOG-FILE" /&gt; 
      &lt;appender-ref ref="STDOUT" /&gt; 
    &lt;/root&gt; 
  </code></pre>
  
  <p>But I am not able to see any result related to log4j2.xml (Any congiguration needed ? )</p>
  
  <p>Please help. Thanks in advance.</p>