Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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!

0 votes


Accepted answer

Permanent link
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.
Isabel Murakami selected this answer as the correct answer

1 vote

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: May 09 '14, 1:48 p.m.

Question was seen: 27,111 times

Last updated: May 11 '14, 9:06 p.m.

Confirmation Cancel Confirm