apache / apache/logging-log4j2
Rollover not works appropriotely with CronTriggeringPolicy and SizeBasedTriggeringPolicy
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.7k
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 27
Description
## Description
Rollover does not work appropritely when combining `CronTriggeringPolicy` and `SizeBasedTriggeringPolicy`.
In more detail, (1) After `CronTriggerinPolicy` has triggered,(2) before enough time passed for the the filename to change, `SizeBasedTriggeringPolicy` is ignored.
In this case, rollover does not occur, and logs continue to accumulate in the same file. Additional logs may even be lost after gzip if you have configured gzip.
``` xml
```
For instance, with above configuration, `CronTriggeringPolicy` will make new log file named `"test.1800.3.log"` at 18:00:00 (if it is a third file), and if the file grow upto 100MB by 18:00:30, `SizeBasedTriggeringPolicy` will not work (The new logs will be appended on same file continually or even losted if you configure some compression method). If the time is 18:01:30 not 18:00:30, `SizeBasedTriggerinPolicy` would work fine because the file name have to change.
## Configuration
**Version:** 2.23.1
**Operating system:** [OS and version]
Mac OS M1 arm64 Sonoma
**JDK:** [JDK distribution and version]
temurin 11.0.18
**but OS and JDK no matter**
## Reproduction
https://github.com/minkyu97/log4j2-test
In the repository above, you can reproduce the issue. As you can see in the `log4j2.xml` file, `CronTriggeringPolicy` is set to every minute, and `SizeBasedTriggeringPolicy` is set to 10KB. When you run the `Main` class, initially `SizeBasedTriggeringPolicy` works fine, but after `CronTriggeringPolicy` has triggered at least once, `SizeBasedTriggeringPolicy` doesn't work anymore.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.