org.apache.log4j.RollingFileAppender : MaxBackupIndex limit ?
Hi,
What is the highest value as well as recommended value for log4j.appender.file.MaxBackupIndex?
Per http://logging.apache.org/log4php/docs/appenders/rolling-file.html, they do not mention any limit, so seems to me that the limit would be the java integer size: 2^31-1.
However on this non-official log4j manual at http://issuu.com/jyothiram/docs/log4j-manual , they did the following comment:
MaxBackupIndex int
The MaxBackupIndex option determines the number of previously rolled files to preserve.
This option takes a positive integer value. If set to zero, then no roll over occurs and the log file is simply truncated when it reaches MaxFileSize. This option is set to 1 by default. For efficiency reasons, the value of the MaxBackupIndex option should not surpass 10.
Consider increasing MaxFileSize instead of Max-BackupIndex.
Thanks!
What is the highest value as well as recommended value for log4j.appender.file.MaxBackupIndex?
Per http://logging.apache.org/log4php/docs/appenders/rolling-file.html, they do not mention any limit, so seems to me that the limit would be the java integer size: 2^31-1.
However on this non-official log4j manual at http://issuu.com/jyothiram/docs/log4j-manual , they did the following comment:
MaxBackupIndex int
The MaxBackupIndex option determines the number of previously rolled files to preserve.
This option takes a positive integer value. If set to zero, then no roll over occurs and the log file is simply truncated when it reaches MaxFileSize. This option is set to 1 by default. For efficiency reasons, the value of the MaxBackupIndex option should not surpass 10.
Consider increasing MaxFileSize instead of Max-BackupIndex.
Thanks!
Accepted answer
The highest value will depend on how much disk space you have. But you really need to understand why you want to keep so many log files. MaxBackupIndex times MaxFileSize will give you the maximum size of this particular log4j log file. For example, if MaxBackupIndex is 100 and MaxFileSize is 10MB, then the maximum is 1GB. And this is only for one kind of log files (e.g. jts.log).
If you read the linked document carefully, you will notice that multiple log files will be renamed when the rollover occurs. I doubt that you want the system to rename a huge number of log files from time to time.
If you read the linked document carefully, you will notice that multiple log files will be renamed when the rollover occurs. I doubt that you want the system to rename a huge number of log files from time to time.