I'm using a RollingFile Appender with both Time(daily) and Size Trigger Policies. The filePattern ( used for renaming the file on rollover) contains:
filePattern="app-${sys:node}-%d{yyyyMMdd}-%i"
I would like to add a random id ( ideally an uuid) to the rolled file name. Normally, the date pattern and the integer counter would be enough to unique identify a file...but in my situation the logs are automatically picked up via ftp (and deleted if transferred succesfully). Because of the file deletion it is possible to end up with a duplicate file ( on the ftp , not locally) ... because the %i counter is based on the files that already exist locally.
For instance, having:
- app-20180205-1.log
- app-20180205-2.log
- app-20180205-3.log
and log4j2 currently writing to , let's say : /tmp/app.log
If the 3 files already rolled are transfered via ftp and deleted , on the next rollover , I will have app-20180205-1.log instead of app-20180205-4.log . This is what I'm trying to avoid.
Any solutions?