0

I'm getting the logs from different services and stored in server.log with pattern.

server.log.2019-02-01 ...... ......sever.log.2019-02-15.

Tried in this way

I previously used periodic-rotating-file-handler which doesn't delete the files, so later updated to size-rotating-file-handler which will rotate the logs only if the file reaches to the max value.so, now i'm using the periodic-size-rotating-file-handler which will rotate the logs even if the logs doesn't reach the max value, but older logs are not getting deleted.

My Code:

<size-rotating-file-handler  name="FILE" autoflush="true">
                <formatter>
                    <named-formatter name="PATTERN"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server.log"/>
                <rotate-size value="20M"/>
                <max-backup-index value="5"/>
                <append value="true"/>
                <suffix value=".yyyy-MM-dd"/>
            </size-rotating-file-handler>

Expected Behavior:

I expect the logs files should rotate according to the size and periodic-file-handler does and also should delete the older files keeping 5 days backup.

Rishi
  • 51
  • 2
  • 10
  • If the date suffix is used files will not be deleted. You'd have to use a cron job or something similar to do that. – James R. Perkins Feb 17 '19 at 20:31
  • If i remove the suffix, does it gonna delete the previous files? – Rishi Feb 21 '19 at 20:50
  • Yes if you use only the size rotation those will get purged. – James R. Perkins Feb 21 '19 at 21:26
  • That's great! but what will the format of my files if i remove the date suffix. How will the daily files get appended.Because I need a backup of these files for 5 days. @JamesR.Perkins – Rishi Feb 22 '19 at 22:18
  • The won't be rotated daily, only when the size is reached. But it would look something like `server.log.1`, `server.log.2`, `server.log.3`, etc. – James R. Perkins Feb 24 '19 at 20:43
  • Is there any other option other than cron job to delete the old files? For the mentioned format in the question.@JamesR.Perkins – Rishi Feb 25 '19 at 22:09
  • Not at this time no. There is an open issue with some reasoning as to why this is not currently done https://issues.jboss.org/browse/LOGMGR-139. – James R. Perkins Feb 26 '19 at 15:05

0 Answers0