log4j creates log file but does not write the messages that I am creating

1.9k views Asked by At

Log file is getting created and logs are getting written into it.But , it doesn't write the things that i specify in

LOG.trace("") and LOG.error("") etc.

log4j.rootLogger=INFO,R

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%-5p %c{1}:%L - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.MaxFileSize=20MB
log4j.appender.R.File= /home/raremile/Documents/logsInfer/InferlyticsConsumerStorm.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %r [%t] %-5p %c - %m%n
log4j.appender.R.MaxBackupIndex=10

log4j.appender.Con=org.apache.log4j.ConsoleAppender
log4j.appender.Con.layout=org.apache.log4j.PatternLayout
log4j.appender.Con.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %r [%t] %-5p %c - %m%n
2

There are 2 answers

0
Gonzague On BEST ANSWER
log4j.rootLogger=TRACE,error,R

TRACE is the lowest level of logging, while your current configuration is on INFO which is the highest.

0
Sudheer On

Log4j Logging levels are enabled based on the order

ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL

So, if you enable INFO logging level WARN, ERROR, FATAL log statements will also get logged to file or console. But TRACE log statements will not be logged.