SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

See How Logging Can Be Used in Your Android Application

Explore how the logging component can help make deployed applications more supportable.

Overview

You will learn

  • How to use the Logging component to log messages
  • How to change the log level
  • How to upload and view logs in the SAP Mobile Services cockpit
Bruce Meng B Bruce Meng August 21, 2026
Created on April 26, 2024
Contributors

More from Bruce Meng

See all 8 tutorials by Bruce Meng →

Prerequisites

Prerequisites

Steps

Step 1 Use the logging component

  1. In Android Studio, on Windows, press Ctrl+N, or on a Mac, press command+O, and enter SettingsViewModel to open SettingsViewModel.kt.

  2. On Windows, press Ctrl+F, or on a Mac, press command+F, and enter init to navigate to the init block.

    Note that the following code block contains two logger statements:

Kotlin
init {
    //init from shared preference
    viewModelScope.launch(Dispatchers.Default) {
        preferencesFlow.collect { userReference ->
            logger.debug("get preference as {}", userReference.logSetting)
            _settingUIState.update { uiState ->
                uiState.copy(level = LogPolicy.getLogLevel(userReference.logSetting))
            }
        }
    }

    val consentUsage = UserSecureStoreDelegate.getInstance().consentStatus(ConsentType.USAGE)
    val consentCrashReport =
        UserSecureStoreDelegate.getInstance().consentStatus(ConsentType.CRASH_REPORT)
    logger.debug(
        "init consent data : consentUsage {}, consentCrashReport {}",
        consentUsage,
        consentCrashReport
    )

    ... ...

These messages will be logged when the app’s log level is set to Debug or Path and the app’s Settings menu item is opened.

Step 2 Change the log level
+
Step 3 Upload and view the log
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Use the logging component 2. Change the log level 3. Upload and view the log
Next