27

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?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

23

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

Tony
  • 9,672
  • 3
  • 47
  • 75
Sourabh
  • 1,515
  • 1
  • 14
  • 21
  • Thank you very much, worked for me! Just unpackaged the .jar to a folder, created a .java file containing the code, compiled it into a class, dropped it in the [ log4j-1.2.16\org\apache\log4j ] folder, zipped up the entire contents of the log4j-1.2.16 folder and renamed as a jar, included in build path, and referenced new class in my log4j.xml configuration :) – jp093121 Feb 11 '15 at 16:41
  • 2
    log4j recommends the contributed RollingFileAppender instead of its own, and it does support rollover with MaxBackupIndex and a TimeBasedRollingPolicy. See https://logging.apache.org/log4j/extras/apidocs/org/apache/log4j/rolling/RollingFileAppender.html – Philippe Feb 04 '16 at 18:55
  • @jp093121 May I ask how do you compile the .java file into .class file? I tried copied the content to a .java file then compile it, but many error came up, how do you solve it? – Alanight Jul 25 '17 at 02:17
  • @jp093121 Never mind, I've already solve it, but it seems this method not work perfectly, I mean sometimes it won't work, is that bugs or I did anything wrong? – Alanight Jul 25 '17 at 07:12