Sriram R created LOG4J2-3313: -------------------------------- Summary: Rolling file process with tempCompressedFilePattern Key: LOG4J2-3313 URL: https://issues.apache.org/jira/browse/LOG4J2-3313 Project: Log4j 2 Issue Type: Improvement Components: Appenders Affects Versions: 2.15.0 Environment: I don't think the environment matters here but tested on macOS Big Sur [ v 11.5.2 ]
Reporter: Sriram R Attachments: Screenshot 2022-01-04 at 8.52.49 PM.png Let us take an example where we have a RollingFile appender with a DefaultRollOverStrategy. Let's consider the following values for {code:java} fileName = "logs/test.log" filePattern = "logs/%d{yyyy-MM-dd}/test-%d{yyyy-MM-dd-HH-mm}.%i.log.gz" {code} When a rollover takes place, log4j2 first renames test.log and moves it to the filePattern path, and then compresses the file {code:java} [ logs/test.log -> logs/2022-01-03/test-2021-01-03-01.1.log -> logs/2022-01-03/test-2021-01-03-01.1.log.gz{code} Now let's consider a scenario where we also use tempCompressedFilePattern with DefaultRolloverStrategy. {code:java} tempCompressedFilePattern = "tmp/%d{yyyy-MM-dd}/test-%d{yyyy-MM-dd-HH-mm}.%i.log.gz" {code} In this scenario, I would expect test.log to be renamed and moved to `tmp` folder before being compressed but that's not the case IDEAL SCENARIO {code:java} logs/test.log -> tmp/test-2022-01-03-01.log -> tmp/test-2022-01-03-01.log.gz -> logs/2021-01-03/test-2022-01-03-01.log.gz{code} But this happens [ difference in step2 from IDEAL SCENARIO ] {code:java} logs/test.log -> logs/test-2022-01-03-01.log -> tmp/test-2022-01-03-01.log.gz -> logs/2021-01-03/test-2022-01-03-01.log.gz{code} Here, even though the temp pattern folder is different, a temporary file is created in the destination which is then moved to tmp path. Added attachment below on DEBUG log -- This message was sent by Atlassian Jira (v8.20.1#820001)