-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Round initialTime in RollingFileManager #3872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Conversation
While @ppkarwasz is the main figure stewarding #3068 and this one, I'd appreciate one or more new tests and a changelog entry. |
@vy If you have an idea on how to test this properly, I'm happy to write a test. |
@kelunik, create a package-private |
@vy I've added a test now in a similar way like you suggested. It tests the rounding now, but doesn't test the fact that initial time actually rounds. I've also modified the test in the second commit to actually call |
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
Outdated
Show resolved
Hide resolved
Caching of filesystem timestamps (at least in ext4 on Linux) results in non-accurate creation timestamp. Thus, let's round it to the second. Rounding is also applied for the lastModified time, but I'm not sure whether it's needed there. Fixes apache#3068.
Rounding the creation date from the filesystem might address the immediate issue, but I was wondering if it might be more robust to initialize the policy using the file’s last modification date instead:
Would you see any downsides to this alternative? |
Yes, see #3068 (comment)
Additionally, relying on the creation date isn't a known issue, so no action needed here IMO. |
@ppkarwasz Seems like the same caching also applies to the modification time, as I suspected, see https://stackoverflow.com/q/14392975/2373138. |
To counteract this problem the My point here is that no Java API allows us to change the creation date, but with the last modification date we have full control. |
Caching of filesystem timestamps (at least in ext4 on Linux) results in non-accurate creation timestamps.
Thus, let's round it to the second.
Rounding is also applied for the lastModified time, but I'm not sure whether it's needed there.
Fixes #3068.
✅ Required checks
🧪 Tests (select one)
📝 Changelog (select one)
src/changelog/.2.x.x
. (See Changelog Entry File Guide).