[slf4j-user] slf4j on Android with log4j

Jeff Ishaq jishaq at gmail.com
Sat Sep 14 05:36:30 CEST 2013


Hey folks,

I am about 75% of the way there, but still scratching my head - can you
please provide some guidance?

I have an Android project, and I would like our logging to appear:

1) In the Android LogCat tool (to keep our Android developers happy); and,
2) A logfile on disk

I understand that slf4j is an abstraction layer, and one must include
'bindings' to hook up the slf4j API to one or more concrete logging
components.  Furthermore, I see there is an Android-specific adaptation of
slf4j called slf4j-android-1.6.1.  The benefit of the slf4j-android
adaptation seems to be that it has a built-in binding to LogCat.

So one ancillary question I have is why this is a repackaging of the slf4j
code, when it seems like the preferred architecture would be simply to
implement a slf4j-to-Android-logcat binding -- perhaps slf4j doesn't
directly work on Android without some rejiggering.  So I can accomplish 1)
above by using slf4j-android.

Then, to accomplish 2), I suppose I should use log4j to handle this because
it's been around for a very long time and therefore it's likely to be very
stable, which is important to us.  But log4j doesn't work on Android off
the shelf, due to its requirement of some java.beans.* classes that Android
doesn't implement; so, there android-logging-log4j to the rescue!  This
basically provides an alternate means of configurating log4j without using
the missing java.beans class(es).  Works for me.  So by adding
log4j-1.2.17.jar and android-logging-log4j-1.0.3.jar, I get log4j support
in my Android app.

So here is where I'm not clear - how do I tie all of this together?  It
seems like I would need a slf4j-android to log4j-1.2 binding, and I'm not
seeing this anywhere.

Please clue me in.  Thanks very much for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20130913/e1042350/attachment.html>


More information about the slf4j-user mailing list