0

I want to save logs on Android using tinylog and I have added dependencies and configuration file. Sometimes the file is created with content and other times the file is empty. It seems like random behavior. Also the app has writing and reading permissions.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I have added this on graddle.

implementation 'org.tinylog:tinylog-api:2.1.0'
implementation 'org.tinylog:tinylog-impl:2.1.0'

I have put my tinylog.properties file inside src/main/resources

writer1 = logcat
writer1.level = debug

writer2 = rolling file
writer2.level = trace
writer2.format = {date} [{thread}] {level}:\n{message}
writer2.file  = /storage/emulated/0/app/logs/log_{date:yyyyMMdd}.txt
writer2.charset  = UTF-8
writer2.append = true
writer2.policies = daily: 03:00

writingthread = true
Community
  • 1
  • 1
JuanDYB
  • 590
  • 3
  • 9
  • 23
  • Actually, your configuring looks fine. The property `writer2.append = true` does nothing, but this won't be the cause for your issue. Do you use a real phone or an emulator? Is the time unequal 3am? Are the missing log entries output via logcat? – Martin Oct 21 '20 at 19:56
  • I have just updated the official Android example (https://github.com/pmwmedia/tinylog-android-example) to use the rolling file writer. Logging works reliable using this example with Android Studio 4.1 and emulated Android 10. – Martin Oct 21 '20 at 22:36
  • did you find the solution for this JuanDYB ? – Batz Apr 21 '21 at 09:30

0 Answers0