Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

📄The reliable, generic, fast and flexible logging framework for Android

License

NotificationsYou must be signed in to change notification settings

tony19/logback-android

Repository files navigation

Overview

logback-android is a lite version oflogback 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

SeeWiki for documentation.

Forlogback-android@1.x, see the1.x branch.

Quick Start

  1. Create a new "Basic Activity" app inAndroid Studio.

  2. Inapp/build.gradle, add the following dependencies:

    dependencies {  implementation'org.slf4j:slf4j-api:2.0.7'  implementation'com.github.tony19:logback-android:3.0.0'}

    If usinglogback-android in unit tests,eitheruse Robolectric,or use this config instead:

    dependencies {  implementation'org.slf4j:slf4j-api:2.0.7'  implementation'com.github.tony19:logback-android:3.0.0'  testImplementation'ch.qos.logback:logback-classic:1.2.11'}configurations.testImplementation {  excludemodule:'logback-android'}
  3. Createapp/src/main/assets/logback.xml containing:

    <configurationxmlns="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">  <appendername="logcat"class="ch.qos.logback.classic.android.LogcatAppender">    <tagEncoder>      <pattern>%logger{12}</pattern>    </tagEncoder>    <encoder>      <pattern>[%-20thread] %msg</pattern>    </encoder>  </appender>  <rootlevel="DEBUG">    <appender-refref="logcat" />  </root></configuration>
  4. InMainActivity.java, add the following imports:

    importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;
  5. ...and modifyonOptionsItemSelected() to log "hello world":

    @OverridepublicbooleanonOptionsItemSelected(MenuItemitem) {Loggerlog =LoggerFactory.getLogger(MainActivity.class);log.info("hello world");// ...}
  6. Build and start the app.

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

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

Download

Gradlerelease

dependencies {  implementation'org.slf4j:slf4j-api:2.0.7'  implementation'com.github.tony19:logback-android:3.0.0'}

Gradlesnapshot (unstable)

repositories {  maven { url'https://oss.sonatype.org/content/repositories/snapshots' }}dependencies {  implementation'org.slf4j:slf4j-api:2.0.7'  implementation'com.github.tony19:logback-android:3.0.1-SNAPSHOT'}

Build

Use these commands to create the AAR:

git clone git://github.com/tony19/logback-android.gitcd logback-androidscripts/makejar.sh

The file is output to:

./build/logback-android-3.0.0-debug.aar

Release

  1. CD into./scripts/release.

  2. Install deps:npm install

  3. Make surelocal.properties contains the following keys, required to sign artifacts and upload to Maven Central:

    # output from `gpg --export-secret-keys <PUBKEY_LAST8> | base64`signing.key=# PUBKEY_LAST8 from `gpg --list-keys` (last 8 digits of pub key)signing.keyId=# password for key (can be empty if key has no password)signing.password=# path to secring.gpg file from `gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg`signing.secretKeyRingFile=/Users/tony/.gnupg/secring.gpg# OSS sonatype username at https://issues.sonatype.orgossrhUsername=# OSS sonatype password at https://issues.sonatype.orgossrhPassword=# profile ID from https://oss.sonatype.org/#stagingProfiles (select profile, and copy profile ID from hash in address bar)sonatypeStagingProfileId=b2413418ab44f
  4. Do a dry-run:npm run start --dry

  5. If everything looks good, rerun without--dry.

  6. Confirm the artifacts were uploaded inhttps://repo1.maven.org/maven2/com/github/tony19/logback-android/3.0.0/.


[8]ページ先頭

©2009-2025 Movatter.jp