-
Notifications
You must be signed in to change notification settings - Fork 476
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
Rolled logs, old files deleted on process (app) restart #310
Comments
Additional info, after more testing: appears to be related to the I have a test run in front of me where the max files is set to 15, and after logging system init, there are 11 files. The app runs for a while, generating more data, then observe log directory and (a) it has generated 6 new rolled log files, but (b) there are only 13 files. So started with 11, added 6 (11 + 6 = 17 files involved). But when those 6 rolled files were added, 4 old files were dropped (11 + 6 added - 4 dropped = 13 left). With my My guess is that dropping old files is (as the parameter name suggests) done in a fuzzy-batching kind of way where once the code sees the number of log files is getting "too many" it deletes "some" files. Not a predictable number. Just "some" to get the count back under the target maximum. But... if that's what's happening, it's pretty severe as I found in an additional test case: I initialized the autorotating file destination with:
Since I set my values after the constructor, the constructor should initially have set things up with defaults, which (looking at the code) are 10 files each 1 mb (1024k). BUT... that produced a VERY unexpected result:
Rather than keeping the two starting log files, it kept one and deleted the other. If the default params are to keep 10 1mb files, how could XCGLogger have decided this was right ?? |
Added info:
|
My problems were ultimately due to not using critical parameter values. I have added code documentation that would have helped me, and created a pull requests from it (no changes other than code comments). Pull request: #311 |
Running app (iOS app) generates log files:
Then app is quit (force quit by user, or invisibly by iOS).
User returns to app (re-launching it).
File state is now:
These files are gone:
Describing effect in words: "when you create a new instance of XCGLogger with same configuration, it loses the previous file set (old, rolled log files) and keeps only the most recent 'active' log file by rolling (renaming) it. Data is lost that should have been kept according to the config for max number of rolled log files to keep."
Swift code for setup:
The text was updated successfully, but these errors were encountered: