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

Log file is not created on Android on power shutdown #758

Open
recser opened this issue Oct 24, 2024 · 6 comments
Open

Log file is not created on Android on power shutdown #758

recser opened this issue Oct 24, 2024 · 6 comments
Labels

Comments

@recser
Copy link

recser commented Oct 24, 2024

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:

  1. Shutdown the device by removing the plug
  2. Start the device, start the application

Environment
tinylog version: 2.4.1
Java version: 17

@recser recser added the bug label Oct 24, 2024
@pmwmedia
Copy link
Member

pmwmedia commented Jan 4, 2025

What is your tinylog configuration?

@recser
Copy link
Author

recser commented Jan 4, 2025

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

@pmwmedia
Copy link
Member

pmwmedia commented Jan 4, 2025

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!?

@recser
Copy link
Author

recser commented Jan 5, 2025

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.

@pmwmedia
Copy link
Member

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?

@recser
Copy link
Author

recser commented Jan 21, 2025

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

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

No branches or pull requests

2 participants