0

Below is the log4j configuration I use. I have set the file limit to 5 MB. But the actual log file size goes beyond 2 GB. Not sure what is going wrong here. Can you identify?

# Root logger option
log4j.rootLogger=ERROR


log4j.logger.com.abcd.wpp=DEBUG,file,stdout

# Redirect log messages to console
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

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/wpp.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Balaji Vignesh
  • 446
  • 1
  • 7
  • 19

1 Answers1

-1

have you tried....?

# Root logger option
log4j.rootLogger=ERROR, file, stdout

log4j.logger.com.abcd.wpp=DEBUG

# Redirect log messages to console
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

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/wpp.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
FedeCz
  • 533
  • 3
  • 4
  • my point is setting the appenders in the rootLogger. Never seen someone do it the way Balaji Vignesh did it. – FedeCz May 23 '17 at 05:36
  • Only because I had tried I am saying that the log file size is greater than 2 GB.. – Balaji Vignesh May 23 '17 at 05:37
  • Okay, I think that is not the solution here. I don't require the Global stdout. I just want the stdout of my package 'abcd'. That is all working perfect. But the file rolling isn't happening – Balaji Vignesh May 23 '17 at 05:39