1

Does Tinylog 1.3.5 (the latest 1.x.x version) support logging into files on Android?

I have tried to get it to work but to no avail. Logging via catlog works. Configuring tinylog via a "tinylog.properties" file also works, as long as "tinylog.writer = catlog".

But even when using this simple tinylog.properties file, no logging file is created:

tinylog.writer = file
tinylog.writer.filename = log.txt

When using version 2.0.0-M2.1 of Tinylog the project compiles but non of the logging commands (Logger.info, Logger.error, etc.) seems to do anything. The target device runs Android SDK 28.


Solution:

This worked for me:

tinylog.writer = file 
tinylog.writer.filename = /data/user/0/com.apppackage.my/files/log.txt
Wayne
  • 13
  • 3

1 Answers1

0

Yes, tinylog supports logging into files on Android. However, the target folder has to be writable for your app. Have you tried tinylog.writer.filename = /data/local/tmp/log.txt for example? If you use an emulator, you get usually tons of logcat output. This output can be helpful to find the cause for the problem. This will probably be missing write permissions of the app for the target folder of the log file.

For tinylog 2, the configuration syntax has been simplified. In your case, your tinylog.properties would be:

writer       = file
writer.file  = /data/local/tmp/log.txt
Martin
  • 598
  • 1
  • 4
  • 27
  • Can you please explain detailed how to configure in android. I have added the tinylog.properties file in main/res directory but I don't know where is the log file created and if it's working well. With regards, – JuanDYB Oct 21 '20 at 06:40
  • You have to put tinylog.properties in src/main/resources. If this directory doesn't exist yet, just create it. – Martin Oct 21 '20 at 11:03
  • I have added the directory and I see that the behaviour is random. In some executions I have the file written and other times the log file is created empty. My app have write permisssions. Thanks! – JuanDYB Oct 21 '20 at 14:43