Skip to Content

See How Logging Can Be Used in Your Android Application

Explore how the logging component can help make deployed applications more supportable.
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
flyingfish162Bruce MengJanuary 27, 2023
Created by
sandeep-tds
January 9, 2023
Contributors
sandeep-tds
jmmargo

Prerequisites

  • Step 1
  • Step 2
    1. Navigate to the entity list screen and open the app’s menu.

      Settings menu button
    2. Choose Settings.

      Settings menu opened
    3. Select Log Level.

      Log level settings option
    4. Set the level to Debug.

      Debug log level option
    5. Navigate back to the entity list screen, then back into the Settings screen to see the effect of changing the log level.

      Settings menu opened
    6. Examine the Logcat (located at the bottom of the Android Studio screen, click it and you can see the logs). In the filter, add the name of the class that we are interested in seeing the log from: com.sap.wizapp.mdui.EntitySetListActivity.

      Notice that the messages were logged since the log level of the app was set to Debug or Path.

      Debug log level output

    The SDK libraries also log output based on the app’s log level.

    1. Change the filter to com.sap.cloud.mobile.foundation.

    2. Press Back to exit the app and you will see the logged lines from the foundation library.

      Debug log level output for foundation
  • Step 3
    1. Navigate back to the Settings menu in the app, and this time tap Upload Log.

      Upload log button in settings menu

      A Toast message is displayed confirming that the upload succeeded.

      Log upload succeeded
    2. In the Mobile Services cockpit, navigate to Mobile Applications > Native/Hybrid > com.sap.wizapp > Mobile Client Log Upload.

      Mobile Applications > Native/Hybrid > com.sap.wizapp > Mobile Client Log Upload
    3. Select the Logs tab and you will see the log you just uploaded in the list. You can download the text messages of the logs by clicking the Download sign. If the log doesn’t appear immediately, wait for a few moments, then click Go to refresh the view.

      View log
    4. You can inspect the log details in the browser by clicking on its table entry. The following screenshot contains the details of the first log.

      View log details
    5. Additionally, you can access the logs locally on an emulator. You can browse the file system of an Android emulator using the Device File Explorer to view the log files as shown below, in data > data > com.sap.wizapp (or the package name of your project) > files.

      View logs in emulator
    6. You can manage the initial log level of the application and the ability for mobile services to accept logs on the Configuration page, as shown below.

      Log Policy

    For further information on logging, see Logging.

    Congratulations! You have explored how you can use the logging feature to debug or support a deployed application.

Back to top