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?
Use MaxBackupIndex in DailyRollingFileAppender -log4j
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
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 :) –
Strobile
log4j recommends the contributed RollingFileAppender instead of its own, and it does support rollover with MaxBackupIndex and a TimeBasedRollingPolicy. See logging.apache.org/log4j/extras/apidocs/org/apache/log4j/… –
Ancier
@Strobile 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? –
Akron
@Strobile 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? –
Akron
© 2022 - 2024 — McMap. All rights reserved.