This example belongs to an article published in Java Magazin 9.17: Android Logging for Java Professionals – SLF4J and Logback in Android.
The original article (:de:) can be found here: Android Logging für Java-Profis – SLF4J und Logback in Android.
An example that shows some possibilities of using logback-android:
- The app issues log statements when pressing a button and displays those in a the main text view (see MainActivity).
- There is an exemplary logback.xml,
- writing to a file (that is rolled over daily) and
- logcat. It also
- forwards JUL to SLF4J/logback.
- The app also provides a PreferencesDeveloperActivity / preferences_developer.xml that allows for
- Setting the root/logcat levels at runtime
- Opening the current logfile in an editor: OpenLogActivity
- Sending all logfiles via email: SendLogActivity
- The central logback-android logic is encapsulated in a separate JAR file: logback-android-utils
Running Jenkinsfile with the pipeline plugin (tested with version 2.4) requires
- A JDK defined as Jenkins tool (see Jenkinsfile for name of JDK tool)
- Android SDK installed on Jenkins salve, matching the
compileSdkVersion
andbuildToolsVersion
as defined in app/build.gradle - Optional: You can add a build parameter
RECIPIENTS
that contains a comma-separated list of all email recipie