Open Ekalips opened 3 months ago
Additional info: the library does "move" the latest log into the tmp file for further processing, so technically data isn't lost when app death happens. The issue is that tmp file is basically forgotten after restart, just left sitting there.
Describe the bug
Hi. We are using a conjunction of Timer and Logback Android to log into files in production environment for further inspection. For this we are using
RollingFileAppender
,SizeAndTimeBasedRollingPolicy
configured to max 40mb log size and/or daily rollovers, the code for it is attached below. The issue we are facing is that we get malformedi.log.gz
files once in a while, way more often that we would want. After thorough research the culprit seems to be the fact that those production devices have quite unexpected lifecycle and might (and oftentimes do) kill our app right at the midnight and restart the device, so what's happening is that app wakes up right after the midnight just to log that it's dying (from lifecycle callbacks), therefore triggering the rollover, but as soon as that happens app is killed and restarted, which seems to cause rollover to stop what it was doing and not recover properly afterwards. I've tried finding similar issues or any solutions for it but no luck really. The only few solutions (hacks) I can see is to reduce the max file size so it rolls over naturally more and the last log file is smaller so it may be able to compress it in time, or trying to not log anything if the app is closing (altho it'll slightly reduce the log usefulness). Are there any official solutions to this or maybe it's an open issue?Reproduction
Logs
No response
logback-android version
3.0.0
OS Version
9
What logback configuration are you using? (logback.xml or Java/Kotlin code)
Validations