Powerful logging for Android
logback-android brings the reliable, fast, and flexible logback framework to Android — log to logcat, files, SQLite, sockets, syslog, and email, all from one XML config.
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'com.github.tony19:logback-android:3.0.0'
}
Why logback-android?
A production-grade logging framework built on the proven logback engine, tuned for Android.
Multiple destinations
Send logs simultaneously to logcat, files, SQLite databases, sockets, syslog, and email — each with its own filters and formats.
Declarative XML config
Change logging behavior without touching code. Drop a logback.xml into your assets, or configure programmatically if you prefer.
Fast and lightweight
A lite port of logback that trims server-only baggage, keeping your APK small and your logging overhead low.
Familiar SLF4J API
Write log statements against SLF4J, the de-facto standard Java logging facade. Code that logs on the server logs the same way on Android.
Android-aware
Built-in variables like ${DATA_DIR}, ${PACKAGE_NAME}, and ${VERSION_NAME} resolve at runtime, so configs work across devices and app versions.
Battle-tested
Powered by the same engine trusted in countless JVM deployments for over a decade, maintained and adapted for Android since 2011.
Quick start
Three steps to structured, configurable logging in your app.
-
Add the dependencies
In your module's
build.gradle:dependencies { implementation 'org.slf4j:slf4j-api:2.0.7' implementation 'com.github.tony19:logback-android:3.0.0' }Supporting devices older than Android 8.0? Use the Java 8 artifact
logback-android-jdk8instead (minSdk 21). -
Create
app/src/main/assets/logback.xmlThis minimal config sends everything at
DEBUGand above to logcat:<configuration xmlns="https://tony19.github.io/logback-android/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://tony19.github.io/logback-android/xml https://cdn.jsdelivr.net/gh/tony19/logback-android/logback.xsd" > <appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender"> <tagEncoder> <pattern>%logger{12}</pattern> </tagEncoder> <encoder> <pattern>[%-20thread] %msg</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="logcat" /> </root> </configuration>Or skip the hand-writing — build it visually with the Config Editor.
-
Log away
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MainActivity extends Activity { private static final Logger log = LoggerFactory.getLogger(MainActivity.class); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); log.info("hello world"); } }
Build your config visually
The interactive Config Editor lets you add and remove loggers and appenders, tweak levels,
patterns, and rolling policies — and generates a ready-to-use logback.xml as you type.