MobileUI
/
Logging
Learn how logging works in our cross-platform environment.
Every MobileUI app comes with cross-platform-enabled logging. In Java applications, the SLF4J logging API has established as an industry standard. MobileUI comes with two implementations of this API for Android and iOS:
- On Android, MobileUI comes with logback-android as transitive dependency. The logback configuration is available in:
[PROJECT-ROOT]/app-android/src/main/assets/logback.xml
- On iOS, MobileUI comes with logback-classic as transitive dependency. The logback configuration is available in:
[PROJECT-ROOT]/app-ios/src/main/resources/logback.xml
Logging Example
Within your business logic, you can use the Logging system as shown in the example below from all modules of your project:
public class MyController {
private static final Logger logger = LoggerFactory.getLogger(MyController.class);
public void myMethod(Exception exception){
logger.debug("A debug message, solution is: {}", 42);
logger.info("An info message");
logger.error("An error message", exception);
}
}
Note Kotlin Devs!: There are many ways to use SLF4J from Kotlin with different advantages and disadvantages. Please refer to the article Idiomatic Logging in Kotlin to learn more.
Viewing your logs
To view your logs,
- on Android: Use the logcat view in Anroid Studio.
- on iOS: Use the Run or Debug view in Android Studio.