2 Replies Latest reply: Jan 7, 2013 8:18 AM by mjmjava RSS

    log4j : logging logs to different appenders

    mjmjava
      Hello,

      i have this as log4j.properties

      log4j.rootCategory = DEBUG,file,Logfile,stdout
      log4j.category.MUTE = OFF

      log4j.appender.stdout.threshold = ERROR
      log4j.appender.stdout = org.apache.log4j.ConsoleAppender
      log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
      log4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} %5p [%t] %c - %m%n

      log4j.appender.file.threshold = ${qtl.log.level}
      log4j.appender.file.File = ${qtl.log.operation}
      log4j.appender.file.MaxFileSize = 10MB
      log4j.appender.file.MaxBackupIndex = 10
      log4j.appender.file = org.apache.log4j.RollingFileAppender
      log4j.appender.file.layout = org.apache.log4j.PatternLayout
      log4j.appender.file.layout.ConversionPattern =%-5p|%-80m|%d%n

      log4j.appender.Logfile.File = ${qtl.log.application}
      log4j.appender.Logfile.MaxFileSize = 10MB
      log4j.appender.Logfile.MaxBackupIndex = 10
      log4j.appender.Logfile = org.apache.log4j.RollingFileAppender
      log4j.appender.Logfile.layout = org.apache.log4j.PatternLayout
      log4j.appender.Logfile.layout.ConversionPattern =%-5p|%-80m|%d%n


      for these two different file appenders , i want to instantiate two different loggers so how can i do it

      at present moment i am instantiating log like this

      String callingClassName = Thread.currentThread().getStackTrace()[2].getClass().getCanonicalName();
      return Logger.getLogger(callingClassName);