[slf4j-user] Logging Filter for Android SLF4J

Fred phreed at gmail.com
Wed Mar 2 16:17:00 CET 2011


On Thu, Feb 24, 2011 at 1:02 AM, Thorsten Möller <thorsten.moeller at unibas.ch>
wrote:
>
> Am 24.02.2011 um 01:38 schrieb Fred:
>
>> Am I just blind?
>> How do you set up filters with the android implementation of slf4j?
>
> As the name "simple logging facade" indicates, neither SLF4J (in general)
nor its Android implementation do provide measures for filtering logging
requests - they are a facade to the underlying logging framework.
Consequently, this is a feature that has to be supported underlying logging
framework. The Android implementation is a facade to the logging framework
of the Android platform, which has simple log level threshold based
filtering, configurable directly in the Eclipse view.
>
> -Thorsten

Although slf4j doesn't necessarily provide measures for filtering logging
requests it seems like that would be part of the implementation.
To that end I have been looking into how such behavior could be added to the
implementation.
The first thing I noticed is that the android logging framework has some
oddities.
1) not really disabling logging.
When the /data/local.prop file (or setprop) has changed the level for a
logger that has no effect on the Log.<level>() but rather on the
corresponding isLoggable().
To accommodating this in AndroidLogger.java I made the following
modification.

> public void trace(final String msg)
> {
>
if (!Log.isLoggable(name, Log.VERBOSE)) return;

Log.v(name, msg);

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/slf4j-user/attachments/20110302/fb89d3c8/attachment.html>


More information about the slf4j-user mailing list