I have an application that uses the RollingFileAppender under log4j 1.2.15
on 64-bit linux on intel.
pru...@host /tmp/pr $ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
I'd like to roll the logs, but effectively want to not have a limit on
how many can be generated. I tried setting the MaxBackupIndex to
something high, like 10 million. However, when the value gets to
100,000 or higher my app pauses. This seems to happen about the time a
roll happens. The pauses seem to get longer the higher the value of
MaxBackupIndex and start at the first roll. If I lower the
MaxBackupIndex things speed up again.
Two things.
1) Is there a better way to say, "just keep rolling"?
2) This seems like a bug. I'd expect the time to be just about the
same regardless of how many files already exist or the value of
MaxBackupIndex, at least up to the limit of an int. I've included two
files, a properties file and a java source. By increasing and
decreasing the value of maxBackupIndex I've been able to reproduce
this on the two systems I've tested on.
Thanks for your help and your great software, I've been a happy log4j
user for quite a while.
Paul
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=1KB
log4j.appender.file.maxBackupIndex=1000000
log4j.appender.file.File=test.log
log4j.appender.file.threshold=info
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=TRACE, file
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class MBI {
private static Logger logger = Logger.getLogger(MBI.class);
public static void main(String args[]) {
PropertyConfigurator.configure("log4j.properties");
int max = 1000;
for (int i = 0; i < max; i++) {
logger.info("TEST " + i);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]