log4j - Not able to write any contain into log file though empty file created -


used below configuration log message both console , file. see console output. though file created not have contain

status = error name = propertiesconfig  property.filename = c:/target/rolling/rollingtest.log  filter.threshold.type = thresholdfilter filter.threshold.level = debug  appender.console.type = console appender.console.name = stdout appender.console.layout.type = patternlayout appender.console.layout.pattern = %d{yyyy-mm-dd't'hh:mm:ss.sssxxx} %-5p [%t] %x %c %m - %m%n  appender.rolling.type = rollingfile appender.rolling.name = rollingfile appender.rolling.filename = ${filename} appender.rolling.filepattern = c:/target/rolling2/test1-%d{mm-dd-yy-hh-mm-ss}-%i.log.gz appender.rolling.layout.type = patternlayout appender.rolling.layout.pattern = %d{yyyy-mm-dd't'hh:mm:ss.sssxxx} %-5p [%t] %x %c %m - %m%n appender.rolling.policies.type = policies appender.rolling.policies.time.type = timebasedtriggeringpolicy appender.rolling.policies.time.interval = 2 appender.rolling.policies.time.modulate = true appender.rolling.policies.size.type = sizebasedtriggeringpolicy appender.rolling.policies.size.size=1kb appender.rolling.strategy.type = defaultrolloverstrategy appender.rolling.strategy.max = 5  logger.rolling.name = com.example.my.app logger.rolling.level = debug logger.rolling.additivity = false logger.rolling.appenderref.rolling.ref = rollingfile  rootlogger.level = info rootlogger.appenderref.stdout.ref = stdout 

i have tested properties , seem okay me. consider following:

  • to catch messages file need code produce debug messages
  • to catch messages file log messages have produced classes having qualified names starting com.example.my.app

here example worked:

package com.example.my.app;   import org.apache.logging.log4j.logmanager; import org.apache.logging.log4j.logger;  public class main {      logger logger = logmanager.getlogger();      logger getlogger(){         return logger;     }      public static void main(string[] args) {         main mainobj = new main();         mainobj.getlogger().debug("test debig");     }  } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -