Popularity
7.0
Growing
Activity
5.6
-
1,152
46
168

Code Quality Rank: L4
Programming language: Java
License: Apache License 2.0
Tags: Other    
Latest version: v3.0-3

logback-android alternatives and similar packages

Based on the "Other" category.
Alternatively, view logback-android alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of logback-android or a related project?

Add another 'Other' Package

README

logback-android GitHub release CircleCI Codacy Badge

Overview

logback-android is a lite version of logback that runs on Android. This library provides a highly configurable logging framework for Android apps, supporting multiple log destinations simultaneously:

  • files
  • SQLite databases
  • logcat
  • sockets
  • syslog
  • email

Runs on Android 2.3 (SDK 9) or higher. See Wiki for documentation.

For [email protected], see the 1.x branch.

Quick Start

  1. Create a new "Basic Activity" app in Android Studio.
  2. In app/build.gradle, add the following dependencies:

    dependencies {
      implementation 'org.slf4j:slf4j-api:1.7.36' // slf4j 2.x not yet supported
      implementation 'com.github.tony19:logback-android:2.0.0'
    }
    

If using logback-android in unit tests, either use Robolectric, or use this config instead:

```groovy
dependencies {
  implementation 'org.slf4j:slf4j-api:1.7.36' // slf4j 2.x not yet supported
  implementation 'com.github.tony19:logback-android:2.0.0'
  testImplementation 'ch.qos.logback:logback-classic:1.2.11'
}

configurations.testImplementation {
  exclude module: 'logback-android'
}
```

NOTE: SLF4J 2.x is not yet supported.

  1. Create app/src/main/assets/logback.xml containing:

    <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>
    
  2. In MainActivity.java, add the following imports:

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
  3. ...and modify onOptionsItemSelected() to log "hello world":

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Logger log = LoggerFactory.getLogger(MainActivity.class);
        log.info("hello world");
        // ...
    }
    
  4. Build and start the app.

  5. Open logcat for your device (via the Android Monitor tab in Android Studio).

  6. Click the app menu, and select the menu-option. You should see "hello world" in logcat.

Download

Gradle release

dependencies {
  implementation 'org.slf4j:slf4j-api:1.7.36' // slf4j 2.x not yet supported
  implementation 'com.github.tony19:logback-android:2.0.0'
}

Gradle snapshot (unstable)

repositories {
  maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {
  implementation 'org.slf4j:slf4j-api:1.7.36' // slf4j 2.x not yet supported
  implementation 'com.github.tony19:logback-android:2.0.1-SNAPSHOT'
}

Build

Use these commands to create the AAR:

git clone git://github.com/tony19/logback-android.git
cd logback-android
scripts/makejar.sh

The file is output to: ./build/logback-android-2.0.0-debug.aar