SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

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

🎓 beginner 15 min. SAP BTP Sdk For AndroidBeginnerAndroidMobileSAP Business Technology Platform

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 January 7, 2026
Created by April 26, 2024
Contributors

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

Learn more →