You may clone an existing project from GitHub repository to start with this tutorial.

Step 1: Define client log policy in Mobile Services cockpit
SAP Cloud Platform Mobile Services provides administrators, developers and support staff with extensive logs and traces functionality to troubleshoot application issues. You can control the amount of information that is captured by setting the log level for individual logging components.
In this step, you will enable client log upload policy in SAP Cloud Platform Mobile Services Cockpit for a given MDK app.
-
Login to Mobile Services Cockpit, click com.sap.mdk.demo
| Mobile Client Log Upload.
-
Check Log Upload option and click Save.
Other policy parameters like Log Level, Delete Uploaded Log After, Maximum Number of Logs and Maximum Log Size currently have no effect.
You can find more details about Client Log Upload feature.
Step 2: Create log actions
Logs help you trace events that occur while your application is running. You can create logging actions, set their priority levels and upload stored log entries.
You will create 3 actions:
-
Log action of Type SetState
: to turn the logger On, Off or Toggle
-
Log action of Type SetLevel
: to set log level (Debug, Info, Warn or Error)
-
Log action of Type Upload
: to upload logs from app to Mobile Services
You can find more details about MDK Log Actions.
-
Create a log action of type SetState
:
Right-click the Actions folder | MDK: New Action | choose MDK Log Actions in Category | click Log Action | Next.
Provide the below information:
Property |
Value |
Action Name |
LogSetState |
Type |
Select SetState from the dropdown |
LoggerState |
Select On from the dropdown |
Click Next and then Finish on the confirmation step.
-
Create a log action of type SetLevel
:
Right-click the Actions folder | MDK: New Action | choose MDK Log Actions in Category | click Log Action | Next.
Provide the below information:
Property |
Value |
Action Name |
LogSetLevel |
Type |
Select SetLevel from the dropdown |
Level |
Select Debug from the dropdown |
Setting log level to debug is not recommended for productive environment.
Click Next and then Finish on the confirmation step.
-
Create a log action of type Upload
:
Right-click the Actions folder | MDK: New Action | choose MDK Log Actions in Category | click Log Action | Next.
Provide the below information:
Property |
Value |
Action Name |
LogUpload |
Type |
Select Upload from the dropdown |
Click Next and then Finish on the confirmation step.
Step 3: Bind Set Level log action to the success of Set State action
Double click the LogSetState.action
file | expand Common Action Properties | click the link icon for Success Action and bind it to LogSetLevel.action
Step 4: Bind Set State log action to success of InitializeOffline action
When the metadata is downloaded from App Update, OnDidUpdate
event is being called which eventually triggers InitializeOffline.action
. You can look at Application.app
file for the details.
You will bind LogSetState.action
at success of InitializeOffline.action
.
Navigate to DemoSampleApp
| Actions
| Service
| InitializeOffline.action
| scroll-down and expand Common Action Properties section | click the link icon for Success Action and bind it to LogSetState.action
Step 5: Define success/failure messages for Log Upload action
You will define two message actions for displaying success or failure when Log upload action is triggered. Later, you will bind these actions in Common Action Properties of LogUpload.action
.
-
You will create a success message action.
Right-click the Actions folder | MDK: New Action | choose MDK Message Actions in Category | click Message Action | Next.
Provide the below information:
Property |
Value |
Action Name |
LogUploadSuccessful |
Type |
Select ToastMessage from the dropdown |
Message |
Log File Uploaded |
NumberOfLines |
1 |
Duration |
3 |
IsIconHidden |
Select true from the dropdown |
Animated |
Select true from the dropdown |
Click Next and then Finish on the confirmation step.
-
Create a failure message action.
Right-click the Actions folder | MDK: New Action | choose MDK Message Actions in Category | click Message Action | Next.
Provide the below information:
Property |
Value |
Action Name |
LogUploadFailure |
Type |
Select Message from the dropdown |
Message |
Uploading log file failed |
Title |
Log Upload Failed |
OKCaption |
OK |
OnOK |
--None-- |
CancelCaption |
leave it blank |
OnCancel |
--None-- |
Click Next and then Finish on the confirmation step.
-
Bind both actions in Common Action Properties of LogUpload.action
.
Double click the LogUpload.action
and provide the below information:
Property |
Value |
Success Action |
Click the link icon and bind it to LogUploadSuccessful.action |
Failure Action |
Click the link icon and bind it to LogUploadFailure.action |
Show Activity Indicator |
Select true from the dropdown |
Activity Indicator Text |
Uploading Logs... |
Step 6: Add Upload Log button to main page
You will add a toolbar item to the main page called Upload Logs. You will link toolbar item to LogUpload.action
you just created in step 2.
-
In Main
page, drag and drop an Toolbar Item to the bottom right of the page.
-
Replace Caption to Upload Logs.
-
In the Properties pane, click the Events tab, click the link icon for the OnPress
property to open the object browser.
Double click the LogUpload.action
action and click OK to set it as the OnPress
Action.
Step 7: Deploy and activate the application
Deploy the updated application to your MDK client.
-
Right-click Application.app
and select MDK: Deploy.
-
Select deploy target as Mobile Services.
You should see Deploy succeeded message.
Step 8: Test the application
-
Re-launch the app on your device, you may asked to authenticate with passcode or Biometric authentication. You will see a Confirmation pop-up, tap OK.
At OnLaunch
event, app starts gathering logs.
-
Tap UPLOAD LOGS to upload client logs from app to SAP Cloud Platform Mobile Services.

-
Re-launch the app on your device, you may asked to authenticate with passcode or Biometric authentication. You will see a Confirmation pop-up, tap OK.
At OnLaunch
event, app starts gathering logs.
-
Tap Upload Logs to upload client logs from app to SAP Cloud Platform Mobile Services.

Step 9: Examine uploaded logs in Mobile Services cockpit
Open SAP Cloud Platform Mobile Services Cockpit, click Mobile Applications | Native/Hybrid | click com.sap.mdk.demo
app | Mobile Client Log Upload | Logs.
You may view log entries directly in Mobile Services Cockpit or download them locally.
You can find more details about Uploading and Viewing Client Logs.
Congratulations, you have successfully uploaded client logs to SAP Cloud Platform Mobile Services and you are now all set to Extend an MDK App with Customer Orders.