ppkarwasz commented on issue #1714:
URL: 
https://github.com/apache/logging-log4j2/issues/1714#issuecomment-1685374175

   A `messages.loig.%d{yyyyMMddHHmmssSSS}-%i.gz` should work without 
overwriting any files. Can you confirm that you configuration does not work 
with this pattern?
   
   In your original question you had `messages.log.%d{yyyyMMddHHmmssSSS}.gz` as 
file pattern and this **does not** work if you mix up time-based triggering 
policies, size-based triggering policies together with a 
`DefaultRolloverStrategy`, because:
    * only time-based triggering policies determine the timestamp for the 
`%d{...}` pattern,
    * when a size-based triggering policy causes a rollover, the timestamp of 
the last **time-based** triggering policy is used, which inevitably leads to an 
overwrite.
    
    What you are probably looking for is the `DirectWriteRolloverStrategy` (cf. 
[documentation](https://logging.apache.org/log4j/2.x/manual/appenders.html#directwrite-rollover-strategy)),
 which uses a different timestamp for each rollover. With this strategy, 
omitting the `%i` should be safe (I suppose you won't have multiple rollovers 
per millisecond):
    
    ```
   appender.file.type = RollingFile
   appender.file.name = file
   appender.file.filePattern = /tmp/data/messages.log.%d{yyyyMMddHHmmssSSS}.gz
   appender.file.policies.type = Policies
   appender.file.policies.size.type = SizeBasedTriggeringPolicy
   appender.file.policies.size.size = 500KB
   appender.file.policies.time.type = CronTriggeringPolicy
   appender.file.policies.time.schedule = 0 0/2 * * * ?
   appender.file.policies.time.evaluateOnStartup = true
   ```
   
   NB: the `DirectWriteRolloverStrategy` is automatically activated if you omit 
`fileName`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to