Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure slf4j-android?

Tags:

android

slf4j

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

like image 937
Mikhail Boyarsky Avatar asked Nov 11 '22 03:11

Mikhail Boyarsky


1 Answers

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.

like image 76
marekdef Avatar answered Nov 15 '22 05:11

marekdef