No logging framework implementation when enabling proguard on Android
See original GitHub issueHi, I’m using tinylog version 2.0.0 on Android and it worked great. However I recently released my new app and I found out that the log file never gets created. So I started to investigate the issue. What I found out is that as soon as I enable proguard on my release build I receive following output on the logcat when I log something
LOGGER WARN: No logging framework implementation found in classpath. Add tinylog-impl.jar for outputting log entries.
My tinylog.properties file looks like this
writer=rolling file
writer.file=/data/data/test.grill.com/files/test_logs/test_log.txt
writer.level=info
writer.policies=size: 5mb
writer.format={date: HH:mm:ss.SSS} [{thread}] {level}:\n{message}
and it is located in my resources folder. Everything is working when I’m not enabling proguard. Are there some proguard rules which needs to be added when using tinylog with proguard?
Edit: seems that the ServiceLoader could not get anyResourses
classLoader.getResources(name);
returns an empty Enumeration when enabling proguard.
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (7 by maintainers)
Top GitHub Comments
I found a workaround to tell ProGuard to keep the service files:
ProGuard rules:
I plan to add these
ServiceLoader
calls directly in tinylog 2.1 to make logging with tinylog for Android developers much more convenient when using ProGuard.For tinylog 3, I’m experimenting with a builder concept for instantiation of logging providers, writers, and policies. Then, even no ProGuard rules nor any workaround will be required for tinylog. This will also solve #127.
The problem is that tinylog cannot find
TinylogLoggingProvider
and other classes, which are loaded byServiceLoader
, because Proguard renames all classes. If configure Proguard to keep all tinylog class names, logging should work again: