0

Is there a way to set the fileName prefix for the rolled over file?

I use date for log files, i.e: 21-06-2017.log And have set the max file size to 10MB. So when the file size reaches 10MB, rollover is performed and the current file is renamed to 21-06-2017.log.1 and so on...

I have a process which reads the files with extension .log and render it on UI

Also I'm using properties file and change the fileName programatically when my Spring loads.

Any idea how this can be achieved?

[EDIT]

Even if the RolledOver files are named as 21-06-2017_1.log, that would be fine. Also any type of prefix is acceptable, the only end criteria is that the file name should end with ".log"

  • See this post.: https://stackoverflow.com/questions/13609089/how-to-append-rolling-index-before-file-extension-in-log-filename – arnabkaycee Jun 21 '17 at 16:07
  • @arnabkaycee i found that property is for log4net and I'm using log4j. Thanks for the quick response. – Hitesh Hotchandani Jun 21 '17 at 16:15
  • Oops. My Bad. Try this post. https://stackoverflow.com/questions/25343866/log4j-file-extension-log-disappears-after-using-datepattern – arnabkaycee Jun 21 '17 at 16:26
  • @arnabkaycee Thanks again, but this post uses org.apache.log4j.rolling.RollingFileAppender (which is from apache extras package) instead of org.apache.log4j.RollingFileAppender. The disadvantage of this is I wont be able to set MaxFileSize and MaxBackupIndex on the appender. – Hitesh Hotchandani Jun 21 '17 at 16:36

0 Answers0