Reputation: 3038
I use slf4j-android in my Android application.
The doc says if I write log.trace
then it's the almost the same as I write Log.v
.
But the default logging level seems to be INFO, and logcat shows only log.info
and above, and I can't see how can I change the defaults.
1) How can I configure slf4j-android
2) If I can't: are there any other slf4j implementations for Android, more configurable
Upvotes: 9
Views: 3707
Reputation: 767
It's a pain, but I won't give up on slf4j
. This is what I ended up doing:
public class MyActivity extends AppCompatActivity {
private final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(this.getClass().getName());
...
}
#!/bin/sh
# Add as many lines as needed to set the logging for
# all the activities in your app
adb shell setprop log.tag.MyActivity "$1"
Terminal
view in Android Studio
and just run the script:$ sh adb-setloglevel VERBOSE
Upvotes: 0
Reputation: 481
For example if your tag is MyClass
type in command line
adb shell setprop log.tag.MyClass DEBUG
The way I found is this procedure Find logger slf4j-android source here
You should see that all methods are preceded by if (isLoggable(...)) that in turn call android.util.Log isLoggable which can be found on opengrok
The description of this method explains how to set a proper property.
Note that slf4j-android will rename longer tags i.e. WiFiDirectBroadcastReceiver
will be changed to sth like *directBroadcastReceiver
.
As far as I know you cannot use * in setprop calls so you need to manage your tags carefully.
Upvotes: 2