I want to use java.util.logging on Android. I want to configure the logging system with logging.properties. But how can I tell Android using the specific configure file? For
In case one of you only wants to route java.util.logging output from third party libraries, this can achieved pretty easily with SLF4J and its jul-to-slf4j bridge. This works for FINE and FINEST log statements, too, BTW.
Here's the maven dependency
org.slf4j
jul-to-slf4j
${slf4j.version}
To bootstrap it, put the following in your Application class, Roboguice Module or somewhere else where it gets executed before your first log statement. (Configuring this in assets/logging.propertiesseems not to work, unfortunately).
/*
* add SLF4JBridgeHandler to j.u.l's root logger, should be done once
* during the initialization phase of your application
*/
SLF4JBridgeHandler.install();
You can then either
configure all your log statements from assets/logback.xml (using logback-android). See here for a mapping of log levels.
or just use SLF4J-android to forward the log statements to logcat. To do so, just put the following dependency to your classpath, no further config required:
org.slf4j
slf4j-android
${slf4j.version}
I implemented this successfully using
1.7.6
Note:
INFO) are routed to logcat by android. So make sure to apply appropriate filters that avoid duplicates.