1
votes

I have the following Log4J configurations, how I can delete the logs older than one month?

Define the root logger with appender file

log =log/

log4j.rootLogger = ERROR, FILE

Define the file appender

log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender

Set the name of the file

log4j.appender.FILE.File=${log}/server.log

Set the immediate flush to true (default)

log4j.appender.FILE.ImmediateFlush=true

Set the threshold to debug mode

log4j.appender.FILE.Threshold=debug

Set the append to false, should not overwrite

log4j.appender.FILE.Append=true

Set the DatePattern

log4j.appender.FILE.DatePattern='.' yyyy-MM-dd-a

Define the layout for file appender

log4j.appender.FILE.layout=org.apache.log4j.PatternLayout

log4j.appender.FILE.layout.conversionPattern=%m%n

1
i dont think there is any thing of this kind ,you need to delete manually or make an app to do it for youCode Chieftain

1 Answers

0
votes

you need to use RollingFileAppender and set the MaxBackupIndex count.