tags:

views:

4376

answers:

3

Hi,

Can someone please tell me how to use MaxBackupIndex in DailyRollingFileAppender.I know that the RollingFileAppender supports a maxBackupIndex property, but is there any workarounds for using MaxBackupIndex in DailyRollingFileAppender?

+1  A: 

This feature is not available in current stable version (1.2) of Log4j.

Anyway you can explore the following: http ://wiki.apache.org/logging-log4j/DailyRollingFileAppender

Green Techy
A: 

Thanks a lot for your help. I've implemented this. Instead of overwriting the existing DailyRollingFileAppender, I created another class DailyRollingFileAppenderExt and copied the code provided in Wiki.In the log4j.properties file I'm referring to this clss log4j.appender.R=com.test.logger.DailyRollingAppenderExt log4j.appender.R.MaxBackupIndex=1

I'm logging this to testLog.log file. When I change the date to the next day, I don't see any bbackup file, just testLog.log file is present. What can be the reason for this?

I've figured it out.