You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/sdk-android-wizard-app-logging/sdk-android-wizard-app-logging.md
+109-9Lines changed: 109 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,47 @@ time: 15
26
26
27
27
### Use the logging component
28
28
29
+
[OPTION BEGIN [Jetpack Compose-based UI]]
29
30
30
-
1. In Android Studio, on Windows, press **`Ctrl+N`**, or, on a Mac, press **`command+O`**, and enter **`EntitySetListActivity`** to open `EntitySetListActivity.kt`.
31
+
1. In Android Studio, on Windows, press **`Ctrl+N`**, or on a Mac, press **`command+O`**, and enter **`SettingsViewModel`** to open `SettingsViewModel.kt`.
31
32
32
-
2. On Windows, press **`Ctrl+F12`**, or, on a Mac, press **`command+F12`**, and enter **`onOptionsItemSelected`** to move to the `onOptionsItemSelected` method.
33
+
2. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and enter **`init`** to navigate to the `init` block.
34
+
35
+
Note that the following code block contains two logger statements:
36
+
37
+
```Kotlin
38
+
init {
39
+
//init from shared preference
40
+
viewModelScope.launch(Dispatchers.Default) {
41
+
preferencesFlow.collect { userReference ->
42
+
logger.debug("get preference as {}", userReference.logSetting)
"init consent data : consentUsage {}, consentCrashReport {}",
54
+
consentUsage,
55
+
consentCrashReport
56
+
)
57
+
58
+
... ...
59
+
```
60
+
61
+
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.
62
+
63
+
[OPTIONEND]
64
+
65
+
[OPTIONBEGIN [View-based UI]]
66
+
67
+
1. InAndroidStudio, on Windows, press **`Ctrl+N`**, or on a Mac, press **`command+O`**, and enter **`EntitySetListActivity`** to open `EntitySetListActivity.kt`.
68
+
69
+
2. OnWindows, press **`Ctrl+F12`**, or on a Mac, press **`command+F12`**, and enter **`onOptionsItemSelected`** to navigate to the `onOptionsItemSelected` method.
33
70
34
71
Note that the following method contains two LOGGER statements:
35
72
@@ -48,25 +85,56 @@ time: 15
48
85
49
86
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.
50
87
88
+
[OPTIONEND]
89
+
51
90
52
91
### Change the log level
53
92
93
+
[OPTIONBEGIN [JetpackCompose-based UI]]
54
94
55
95
1. Navigate to the entity list screen andopen the app's menu.
56
96
57
97

58
98
59
99
2. Choose **Settings**.
60
100
61
-

101
+
3. Select **Log Level** displayed in **Logging** on the **Settings** screen.
5. Navigate back to the entity list screen, then back into the **Settings** screen to see the effect of changing the log level.
66
106
67
-
4. Set the level to **Debug**.
107
+

108
+
109
+
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.ui.odata.viewmodel.SettingsViewModel`**.
110
+
111
+
Notice that the messages were logged since the log level of the app was set to **Debug** or **Path**.
112
+
113
+

114
+
115
+
---
116
+
117
+
The SDK libraries also log output based on the app's log level.
118
+
119
+
1. Change the filter to **`com.sap.cloud.mobile.foundation`**.
120
+
121
+
2. Press**Back** to exit the app and you will see the logged lines from the foundation library.
122
+
123
+

124
+
125
+
[OPTIONEND]
126
+
127
+
[OPTIONBEGIN [View-based UI]]
128
+
129
+
1. Navigate to the entity list screen andopen the app's menu.
3. Select the **ErrorLogs** tab and you will see the log you just uploaded in the **Error** level list. If the log doesn't appear immediately, wait for a few moments, then click **Go** to refresh the view.
177
+
178
+
4. You can inspect the log details in the browser by clicking on its table entry.
179
+
180
+
5. Select the **Log Files** tab and you will see the log files you just uploaded in the list. You can download the files by clicking **Download**.
181
+
182
+

183
+
184
+
6. Additionally, you can access the logs locally on an emulator. You can browse the file system of an Android emulator using the **Device Explorer** to view the log files as shown below: **data** > **data** > **com.sap.wizapp** (or the package name of your project) > **files**.
185
+
186
+

187
+
188
+
7. 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.
189
+
190
+

191
+
192
+
[OPTION END]
94
193
95
-
1. Navigate back to the **Settings** menu in the app, andthis time tap **UploadLog**.
1. Navigate back to the **Settings** menu in the app, and this time tap **Upload Log** right below **Log Level**.
98
197
99
198
A Toast message is displayed confirming that the upload succeeded.
100
199
@@ -120,6 +219,7 @@ The SDK libraries also log output based on the app's log level.
120
219
121
220

122
221
222
+
[OPTIONEND]
123
223
124
224
>For further information on logging, see [Logging](https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/features/logging/overview.html).
0 commit comments