views:

114

answers:

3

Hi.

Do you know a way to create an infinite number of backup files with the RollingFileAppender?

When I don't specify any maxBackupIndex at all, I end up with only one backup file.

+1  A: 

Instead of infinite, how about Integer.MAX_INT?

Tassos Bassoukos
+1  A: 

It is not possible. See the Log4J API :

The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.

The best you can do is using a very large limit (Integer.MAX_VALUE will be the max).

Benoit Courtine
Unfortunately, the RollingFileAppender freezes when I use Integer.MAX_VALUE. :(
Bernhard V
A: 

You could try using the DailyRollingFileAppender. That way your log only cycles once a day.

Kurt Du Bois