Skip to content
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

RollingFileAppender does not enumerate all existing rollback files and then overwrites logs during rollback creating gaps #236

Open
vladislav-dobzinski-etr opened this issue Mar 28, 2025 · 2 comments

Comments

@vladislav-dobzinski-etr

I'm using log4net for .NET Framework version 2.0.8

RollingFileAppender is used with CountDirection=1

On startup log4net enumerates existing rollback files and sets curSizeRollBackups

Sometimes log4net does not discover ALL existing rollback files and then new rollback is created, deletes an existing file and creates new rollback. This behavior causes gaps in logs.

In attached log4net internal debug file there are issues with B7EBL.log.455, B7EBL.log.459, B7EBL.log.460 files
Files B7EBL.log.455 and B7EBL.log.459 were not discovered and curSizeRollBackups was not set correctly

log4net: File name [b7ebl.log.450] moves current count to [450]
log4net: curSizeRollBackups starts at [450]
...
log4net: Deleted file [E:\zurnalai\B7Logs\B7EBL.log.455]
log4net: Moving [E:\zurnalai\B7Logs\B7EBL.log] -> [E:\zurnalai\B7Logs\B7EBL.log.455]
...
log4net: File name [b7ebl.log.458] moves current count to [458]
log4net: curSizeRollBackups starts at [458]
...
log4net: Deleted file [E:\zurnalai\B7Logs\B7EBL.log.459]
log4net: Moving [E:\zurnalai\B7Logs\B7EBL.log] -> [E:\zurnalai\B7Logs\B7EBL.log.459]
...
log4net: Deleted file [E:\zurnalai\B7Logs\B7EBL.log.460]
log4net: Moving [E:\zurnalai\B7Logs\B7EBL.log] -> [E:\zurnalai\B7Logs\B7EBL.log.460]

log4net.log

@FreeAndNil
Copy link
Contributor

@vladislav-dobzinski-etr can you check whether the fix in #232 solves your problem?

@vladislav-dobzinski-etr
Copy link
Author

No.
Setting didn't help.
Still while enumerating existing files on startup log4net doesn't "see" existing files and then deletes them during rollback.
How log4net decide about file existence?
Potentially files may be analyzed by agent, which collect logs from files to centralized location for analysis or by antivirus software

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants