title: Logging based on levels on log4j in Java
body: <p>Below is the log4j properties and the Java code. All the logs are getting logged only in Debug. I even tried with adding Threshold, no luck yet. I need to log the log statements in a separate file based on log levels.</p>
  
  <p>All the logs are getting logged only in debug log file, and if I remove debug log, then it is getting logged in info log file.</p>
  
  <p>Giving Threshold option also doesn't work.</p>
  
  <pre><code>log4j.rootLogger = OFF
  
  #define the console appender
  log4j.appender.consoleAppender = org.apache.log4j.ConsoleAppender
  # now define the layout for the appender
  log4j.appender.consoleAppender.layout = org.apache.log4j.PatternLayout
  log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
  
  # now define the rollingFIle appender
  log4j.category.com=error, myErrorappender
  log4j.additivity.com=false
  log4j.appender.myErrorappender=org.apache.log4j.RollingFileAppender
  log4j.appender.myErrorappender.File=/Users/uthaman/Documents/workspace/Logging/myErrorlog.log
  log4j.appender.myErrorappender.MaxFileSize=2MB
  log4j.appender.myErrorappender.MaxBackupIndex=2
  log4j.appender.myErrorappender.layout = org.apache.log4j.PatternLayout
  log4j.appender.myErrorappender.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c (%F:%L) - %m%n
  
  
  log4j.category.com=info,myInfoappender
  log4j.additivity.com=false
  log4j.appender.myInfoappender=org.apache.log4j.RollingFileAppender
  log4j.appender.myInfoappender.File=/Users/user/Documents/workspace/Logging/myInfolog.log
  log4j.appender.myInfoappender.MaxFileSize=2MB
  log4j.appender.myInfoappender.MaxBackupIndex=2
  log4j.appender.myInfoappender.layout = org.apache.log4j.PatternLayout
  log4j.appender.myInfoappender.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c (%F:%L) - %m%n
  
  log4j.category.com=debug,myDebugappender
  log4j.additivity.com=false
  log4j.appender.myDebugappender=org.apache.log4j.RollingFileAppender
  log4j.appender.myDebugappender.File=/Users/user/Documents/workspace/Logging/myDebuglog.log
  log4j.appender.myDebugappender.MaxFileSize=2MB
  log4j.appender.myDebugappender.MaxBackupIndex=2
  log4j.appender.myDebugappender.layout = org.apache.log4j.PatternLayout
  log4j.appender.myDebugappender.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c (%F:%L) - %m%n
  </code></pre>
  
  <p>This is the java code where the log statements are logged:</p>
  
  <pre><code>public class Logging {
  
      private static Logger logger = Logger.getLogger(Logging.class);
  
      public static void main(String[] args) {
          logger.error("This is error");
          logger.info("This is info");
          logger.debug("This is debug");
      }
  
  }
  </code></pre>