Log file is not created on Android on power shutdown
Describe the bug The Android application is not creating the log file(and not logging) when the device is forcefully shutdown(power taken off)
To Reproduce Steps to reproduce the behavior:
- Shutdown the device by removing the plug
- Start the device, start the application
Environment tinylog version: 2.4.1 Java version: 17
What is your tinylog configuration?
Hi, this is the configuration :
writer1 = logcat
writer1.level=debug
writer1.format = {message}
writer2 = rolling file
writer2.level=info
writer2.file=#{tinylog.directory}/{pid}_LOG_{date:yyyy-MM-dd_HH-mm-ss}.txt
writer2.backups = 1000
writer2.format = {date: HH:mm:ss.SSS} {level}: {message}
writer2.policies = size: 5mb
What path do use as #{tinylog.directory}? Are you sure that log entries have already been issued before you shut down the device?
According to your configuration, you don't use the writing thread nor buffering. Therefore, tinylog writes all log entries directly into the log files. Maybe there is some buffering from Android itself that prevents persisting the log file before shutdown!?
Hi, i tried to use different locations (first the app folder, now i use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)), i am running on Android 10.
I am not using any threds or buffering and still the data is not written into the file occasionally after an uncontrolled shutdown. The only thing i saw on the devices is that after shutdown it leaves a zombie process in the task manager but since i am using the PID and the data in the name of the file it should not affect the creation or logging into the file for a new instance.
I am also using an atomic number to track the number of instances created in order to stop multiple instances being lunched.
No idea why it does this, but it only works if I shutdown the app manually and start it normally again.
Do you see the log file with the log entries before the shutdown when the app is still running? Do you see the missing log entries in Logcat?
Hi, yes the file is there. Logcat entries are also present but when the device starts the file is not creating. Seems like there is a lock on the folder of the log files