Stealth Rabbi
Stealth Rabbi

Reputation: 10346

Migrating from android.util.log

I'm taking class files in an Android library and moving the non-Android specific classes (data structures, etc.) in to a plain java library. Some of these classes are using android.util.Log for logging. I'd like to retain the logging, but not be dependent on the android logger in my plain java library. Ideally, the logging substitute would still go to the android logger when running in an android program.

What is the best course of action to take here? Can I just substitute in java.util.Logging?

Upvotes: 1

Views: 458

Answers (1)

ByteWelder
ByteWelder

Reputation: 5614

I advise you to use SLF4J in your library and combine it with a Logback implementation for Android.

    [group: 'org.slf4j', name: 'slf4j-api', version: '1.7+']

    [group: 'com.github.tony19', name: 'logback-android-core', version: '1+'],
    [group: 'com.github.tony19', name: 'logback-android-classic', version: '1+']

SLF4J is a library that provides a logging interface without an implementation. Any logging implementation library (like Logback or Log4j) can be compiled into your app to provide the actual logging configuration and output.

Upvotes: 1

Related Questions