2. Spring Android Commons Logging Module

2.1 Introduction

Android provides its own logging API for use in Android applications. However, many Java libraries, including Spring, use a logging abstraction such as Commons Logging or Simple Logging Facade for Java (SLF4j). The Spring Android Commons Logging Module provides a implementation of the Commons Logging API that bridges onto the Android logging system. This allows Java libraries that use Common Logging to run in an Android environment.

2.2 How to get

The spring-android-commons-logging module is required to use Spring Android, since the Spring Framework itself requires Commons Logging. In general, rely on transitive dependency resolution to include this module in your classpath. We do not recommend using the Commons Logging API directly in your own Android applications; rather, use this module simply to adapt existing code onto the Android logging system. The definition of the module artifact is provided for reference below:

<dependency>
    <groupId>org.springframework.android</groupId>
    <artifactId>spring-android-commons-logging</artifactId>
    <version>${org.springframework.android-version}</version>
</dependency>
		

2.3 Log Level mapping

The Commons Logging API nearly maps directly onto the Android Logging API. There is one difference. The Commons Logging FATAL level maps to the ERROR Android level, since Android has no FATAL level.