Giter Site home page Giter Site logo

sebkur / logback-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tony19/logback-android

0.0 1.0 0.0 45.03 MB

๐Ÿ“„The reliable, generic, fast and flexible logging framework for Android

License: Apache License 2.0

Shell 0.33% Java 98.87% TypeScript 0.78% Roff 0.02%

logback-android's Introduction

logback-android GitHub release API 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

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.1'
    }

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

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

    NOTE: SLF4J 2.x is not yet supported.

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

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

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

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

  8. 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.1'
}

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.2-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.1-debug.aar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.