Giter Site home page Giter Site logo

slf4j-android's Introduction

SLF4J binding for the Android logger

  • Does not support SLF4J markers, these will be ignored.
  • Compatible with API version 1.

Configuration

  • Loads properties from /uk/uuid/slf4j/android/config.properties.
  • Configuration can be applied per logger prefix or set the default by omitting the logger prefix.
    • Set the tag for the specified logger prefix: tag.logger-prefix=TagName
    • Set the log level for the specified logger prefix: level.logger-prefix=SUPPRESS|ERROR|WARN|INFO|DEBUG|VERBOSE|NATIVE
    • Show the logger name in short, compact, long format, or show caller stack frame: showName.logger-prefix=false|short|compact|long|caller
    • Show the current thread: showThread.logger-prefix=true|false
  • With no tag configured, logger names are automatically compacted to fit the Android 23 character tag limit.
  • The default configuration does not show the logger name or the current thread.
  • The default log level is NATIVE (use the Android log level for the tag).
    • The Android log level for each tag is cached at the time the logger is constructed.

Example Configuration File

tag=ExampleApplication
showThread=true
showName=short

Maven Central

  • Available as uk.uuid.slf4j:slf4j-android.
  • The configuration file when using the standard project layout should be located at src/main/resources/uk/uuid/slf4j/android/config.properties.
  • Note: There is a bug in android-maven-plugin that makes the runtime scope unusable.

Maven Usage Example

pom.xml:

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>2.0.7</version>
</dependency>

<dependency>
   <groupId>uk.uuid.slf4j</groupId>
   <artifactId>slf4j-android</artifactId>
   <version>2.0.7-0</version>
</dependency>

Gradle Example

build.gradle:

dependencies {
   compile 'org.slf4j:slf4j-api:2.0.7'
   compile 'uk.uuid.slf4j:slf4j-android:2.0.7-0'
}

slf4j-android's People

Contributors

nomis avatar dependabot[bot] avatar dependabot-preview[bot] avatar lp0 avatar johnjohndoe avatar

Stargazers

 avatar pujh avatar  avatar Rune M. Andersen avatar TAn avatar Kim A. Betti avatar Youcef DEBBAH avatar Christopher-Marcel Esser avatar Oops avatar ssiapp avatar Max Pawlidi avatar  avatar  avatar  avatar  avatar Hisato Shoji avatar Hafize Gungor Kaya avatar Denny Aprilio P avatar countBunny avatar  avatar Shaban Kamel avatar 伊欧 avatar Pine Mizune avatar  avatar  avatar Noah Andrews avatar Wellington Moreno avatar Dang avatar Benjamin Linus avatar Krystian Kałużny avatar Olivia (Zoe) avatar  avatar Vitalii avatar  avatar  avatar Karsten Sperling avatar Niklas Klein avatar Sangkyun Yoon avatar dennis avatar 邵彬 avatar Slawomir Jaranowski avatar Hendy Irawan avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

slf4j-android's Issues

Thank you!

The "official" SLF4J Android is still 1.6.4.

I hope you can propose to slf4j.org to use your implementation instead :-)

crash in android 2.2: String.isEmpty() and Locale.ROOT not found

slf4j uses methods that are not implemented in android 2.2

  • method java.lang.String.isEmpty()
    • referenced from method eu.lp0.slf4j.android.LoggerFactory.getConfig
    • referenced from method eu.lp0.slf4j.android.LoggingConfig.
    • could be easily replaced by ((string == null) || (string.length() == 0))
  • Static field java.util.Locale.ROOT
    • referenced 2 times from LoggingConfig.LoggingConfig()
    • could be easily replaced by Locale.US

runtime:

  • android 2.2 on emulator
  • lib 'org.slf4j', name: 'slf4j-api', version:'1.7.7'
  • lib 'eu.lp0.slf4j:slf4j-android:1.7.6-0'

here is the debug output.

I/dalvikvm﹕ Could not find method java.lang.String.isEmpty, referenced from method eu.lp0.slf4j.android.LoggerFactory.getConfig
W/dalvikvm﹕ VFY: unable to resolve virtual method 524: Ljava/lang/String;.isEmpty ()Z
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0010
D/dalvikvm﹕ VFY: dead code 0x0013-0044 in Leu/lp0/slf4j/android/LoggerFactory;.getConfig (Ljava/lang/String;)Leu/lp0/slf4j/android/LoggerConfig;
I/dalvikvm﹕ Could not find method java.lang.String.isEmpty, referenced from method eu.lp0.slf4j.android.LoggingConfig.
W/dalvikvm﹕ VFY: unable to resolve virtual method 524: Ljava/lang/String;.isEmpty ()Z
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x006e
D/dalvikvm﹕ DexOpt: couldn't find static field
W/dalvikvm﹕ VFY: unable to resolve static field 195 (ROOT) in Ljava/util/Locale;
D/dalvikvm﹕ VFY: replacing opcode 0x62 at 0x00ce
I/dalvikvm﹕ Could not find method java.lang.String.isEmpty, referenced from method eu.lp0.slf4j.android.LoggingConfig.
W/dalvikvm﹕ VFY: unable to resolve virtual method 524: Ljava/lang/String;.isEmpty ()Z
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x00e1
D/dalvikvm﹕ DexOpt: couldn't find static field
W/dalvikvm﹕ VFY: unable to resolve static field 195 (ROOT) in Ljava/util/Locale;
D/dalvikvm﹕ VFY: replacing opcode 0x62 at 0x0120
I/dalvikvm﹕ Could not find method java.lang.String.isEmpty, referenced from method eu.lp0.slf4j.android.LoggingConfig.
W/dalvikvm﹕ VFY: unable to resolve virtual method 524: Ljava/lang/String;.isEmpty ()Z
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0133

W/dalvikvm﹕ Exception Ljava/lang/NoSuchMethodError; thrown during Lde/k3b/android/cellinfo/demo/CellInfoDemoActivity;.
W/dalvikvm﹕ Class init failed in newInstance call (Lde/k3b/android/cellinfo/demo/CellInfoDemoActivity;)
E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.ExceptionInInitializerError
            ...
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NoSuchMethodError: java.lang.String.isEmpty
            at eu.lp0.slf4j.android.LoggerFactory.getConfig(LoggerFactory.java:143)
            at eu.lp0.slf4j.android.LoggerFactory.getLogger(LoggerFactory.java:64)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
            at de.k3b.android.cellinfo.demo.CellInfoDemoActivity.(CellInfoDemoActivity.java:34)
...

Getting exception when add it to android studio 2.1.3

i getting Exception as below:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/slf4j/impl/StaticLoggerBinder;

I am Using Android studio 2.1.3 and java 8

Fatal exception on logging `null`

logger.info(null) on Android throws

java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.println(Log.java:357)
at org.slf4j.impl.AndroidLoggerAdapter.logInternal(Unknown)
at org.slf4j.impl.AndroidLoggerAdapter.log(Unknown)
at org.slf4j.impl.AndroidLoggerAdapter.info(Unknown)

but works fine on other server adapters under SLF4J.

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.