FileTarget - Replace Environment.TickCount with LogEventInfo.TimeStamp#6079
FileTarget - Replace Environment.TickCount with LogEventInfo.TimeStamp#6079
Conversation
WalkthroughAdds a Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
2dc86ef to
8e6e689
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/NLog/Targets/FileAppenders/ExclusiveFileLockingAppender.cs`:
- Around line 128-153: HasFileBeenDeletedTime currently only advances when the
provided timestamp moves ±1s from _lastFileDeletedCheck, which stalls checks if
callers reuse LogEventInfo timestamps; change HasFileBeenDeletedTime (used by
Write) to also compare the wall‑clock (e.g. NLog.Time.TimeSource.Current.Time)
against _lastFileDeletedCheck and trigger the delete/modified logic when the
wall‑clock has advanced more than the threshold even if the input timestamp
hasn’t; update _lastFileDeletedCheck and set FileLastModified from the
wall‑clock in that fallback path so periodic checks still run when event
timestamps are reused or low resolution.
|



Skip operating system call for coarse timestamp, when already have LogEventInfo.TimeStamp (NET11 will make Environment.TickCount slower on Windows in exchange for higher time-precision)