Fork me on GitHub

logback-android

The reliable, generic, fast and flexible logging framework for Java on Android.

Quick Start

  1. Add logback-android and slf4j-api to your project classpath.
  2. Configure logback-android using an XML file or in-code statements. Otherwise, logging is silently disabled.
  3. Use slf4j-api in your application to write logging statements as shown in the example below.

    package com.example;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    import android.os.Bundle;
    import android.app.Activity;
    
    public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        // SLF4J
        Logger LOG = LoggerFactory.getLogger(MainActivity.class);
        LOG.info("hello world");
      }
    }
    

Documentation

Download

OR Maven users can simply add these dependencies to pom.xml:

<dependency>
  <groupId>com.github.tony19</groupId>
  <artifactId>logback-android-core</artifactId>
  <version>1.1.1-2</version>
</dependency>
<dependency>
  <groupId>com.github.tony19</groupId>
  <artifactId>logback-android-classic</artifactId>
  <version>1.1.1-2</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.6</version>
</dependency>

License

EPL v1.0 or (per the licensee's choosing) LGPL v2.1