title: How to set filter in the log4j.xml
body: <p>HI,</p>
  
  <p>In our web application it prints all the logs are printed like Spring and JSF jars files. Which not required for us. How can I set in the log4j.xml file to filter only for our application?</p>
  
  <p><strong>Updated</strong></p>
  
  <p>The following is the configuration we are using for the logging. Can you please tell me whether it is correct? Where I have to add the logger element in the file?</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
  &lt;!-- Log4j Configuration file to log the messages into different logfiles --&gt;
  &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
  
    &lt;appender name="DEBUG" class="org.apache.log4j.RollingFileAppender"&gt;
      &lt;param name="File" value="D:/logs/DEBUGFILE.log"/&gt;
       &lt;param name="Append" value="true"/&gt;
       &lt;param name="MaxFileSize" value="500KB"/&gt;
       &lt;param name="MaxBackupIndex" value="2"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
        &lt;param name="ConversionPattern" value="%d [%t] %p - %m%n"/&gt;
      &lt;/layout&gt;
      &lt;filter class="org.apache.log4j.varia.LevelRangeFilter"&gt;
       &lt;param name="LevelMin" value="DEBUG" /&gt;
        &lt;param name="LevelMax" value="DEBUG" /&gt;
      &lt;/filter&gt;
    &lt;/appender&gt;
  
    &lt;appender name="INFO" class="org.apache.log4j.RollingFileAppender"&gt;
      &lt;param name="File" value="D:/logs/AUDIT_TRAIL.log"/&gt;
      &lt;param name="Append" value="true"/&gt;
       &lt;param name="MaxFileSize" value="500KB"/&gt;
       &lt;param name="MaxBackupIndex" value="2"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
        &lt;param name="ConversionPattern" value="%d [%t] %p - %m%n"/&gt;
      &lt;/layout&gt;
      &lt;filter class="org.apache.log4j.varia.LevelRangeFilter"&gt;
        &lt;param name="LevelMin" value="INFO" /&gt;
        &lt;param name="LevelMax" value="INFO" /&gt;
      &lt;/filter&gt;
    &lt;/appender&gt;
  
    &lt;appender name="ERROR" class="org.apache.log4j.RollingFileAppender"&gt;
      &lt;param name="File" value="D:/logs/ERRORFILE.log"/&gt;
      &lt;param name="Append" value="true"/&gt;
      &lt;param name="MaxFileSize" value="500KB"/&gt;
       &lt;param name="MaxBackupIndex" value="2"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
        &lt;param name="ConversionPattern" value="%d [%t] %p - %m%n"/&gt;
      &lt;/layout&gt;
       &lt;filter class="org.apache.log4j.varia.LevelRangeFilter"&gt;
        &lt;param name="LevelMin" value="ERROR" /&gt;
        &lt;param name="LevelMax" value="ERROR" /&gt;
      &lt;/filter&gt;
    &lt;/appender&gt;
  
    &lt;appender name="FATEL" class="org.apache.log4j.RollingFileAppender"&gt;
      &lt;param name="File" value="D:/logs/FATELFILE.log"/&gt;
      &lt;param name="Append" value="true"/&gt;
      &lt;param name="MaxFileSize" value="500KB"/&gt;
       &lt;param name="MaxBackupIndex" value="2"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
        &lt;param name="ConversionPattern" value="%d [%t] %p - %m%n"/&gt;
      &lt;/layout&gt;
       &lt;filter class="org.apache.log4j.varia.LevelRangeFilter"&gt;
        &lt;param name="LevelMin" value="FATAL" /&gt;
        &lt;param name="LevelMax" value="FATAL" /&gt;
      &lt;/filter&gt;
    &lt;/appender&gt;
  
    &lt;root&gt;
      &lt;priority value="debug"/&gt;
        &lt;appender-ref ref="DEBUG"/&gt;
      &lt;appender-ref ref="INFO"/&gt;
      &lt;appender-ref ref="ERROR"/&gt;
      &lt;appender-ref ref="FATEL"/&gt;
    &lt;/root&gt;
  
  &lt;/log4j:configuration&gt;
  </code></pre>