Home

Awesome

slf4j-timber

Build Status Maven Central Apache License Android Arsenal

SLF4J binding for Jake Wharton's Timber Android logging library

Usage

Just put slf4j-timber, timber and slf4j-api (see note in Download) artifacts to your project and use slf4j like before:

public class YourClass {
  private static final Logger logger = LoggerFactory.getLogger(YourClass.class);

  public void yourMethod() {
    logger.debug("Hello, world!");
  }
}

Don't forget to plant tree to Timber, check Timber usage.

Download

Download the latest AAR or grab it via Maven:

<dependency>
  <groupId>com.arcao</groupId>
  <artifactId>slf4j-timber</artifactId>
  <version>3.1</version>
  <type>aar</type>
</dependency>

or Gradle:

implementation 'com.arcao:slf4j-timber:3.1@aar'

Note: timber and slf4j-api are the transitive dependencies of slf4j-timber, so you don't need to take care of them in Maven POM and Gradle build script.

Transitive dependencies by version

slf4j-timberTimberSLF4J
3.14.7.11.7.25
3.04.4.01.7.21
2.13.1.01.7.12
2.03.0.11.7.12
1.62.7.11.7.12
1.52.5.11.7.7
1.42.4.11.7.7
1.32.2.21.7.7

Binding log4j, Jakarta Commons Logging or java.util.logging over Timber

SLF4J project already contains wrappers for log4j, Jakarta Commons Logging (JCL) and java.util.logging (JUL). You have to include log4j-over-slf4j, jcl-over-slf4j or jul-to-slf4j jar file to your project. These jar files are distributed in SLF4J package.

For Maven and Gradle users it is only about adding new dependency in POM / build script. Below follows the example for log4j, for other bindings it is similar:

Maven:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>log4j-over-slf4j</artifactId>
  <version>1.7.25</version>
</dependency>
<dependency>
  <groupId>com.arcao</groupId>
  <artifactId>slf4j-timber</artifactId>
  <version>3.1</version>
</dependency>

or Gradle:

compile 'org.slf4j:log4j-over-slf4j:1.7.25'
compile 'com.arcao:slf4j-timber:3.1'

Don't forget to exclude log4j transitive dependency from artifact which use log4j, otherwise you can get to trouble with the duplicate classes in Android build system:

Maven:

<dependency>
  <groupId>library</groupId>
  <artifactId>library-using-log4j</artifactId>
  <version>1.0</version>
  <exclusions>
    <!-- excluded, log4j-over-slf4j used instead -->
    <exclusion>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </exclusion>
  </exclusions> 
</dependency>

or Gradle:

compile('library:library-using-log4j:1.0') {
  exclude group: 'log4j', module: 'log4j' /* excluded, log4j-over-slf4j used instead */
}

License

Copyright 2014 Martin Sloup

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.