Client Error Handling with SMP3 – Client Log Upload
Today I want to give you some insights of one feature which is kind of hidden. You might run into the following problem already…
One user of your SMP3 mobile app has a problem with the app. He is telling you (or the support team) that he always gets an exception and after this the app crashed. So how you can debug this problem? Maybe there is no possibility to reproduce this issue on your own device.
One possible solution would be to activate a trace for this specific user inside the SMP3 Management Cockpit. After that ask the user to reproduce the problem. Your app now reads the updated app settings from SMP3 and recognizes that a trace should be enabled. After the issue appeared (or maybe after an user interaction e.g. inside a setting screen) the trace can be uploaded to SMP3.
You (or the support team) can then simply check the client log inside SMP3 Management Cockpit and find out what is going wrong…
For Hybrid App Development you can use the Kapsel Logger Plugin, which can realize this feature out of the box, check out the following link for more information: http://scn.sap.com/docs/DOC-49621
Unfortunately, the native SDK (SMP 3 SP03) does not include this logupload feature yet. But it is quite easy to implement it by yourself. You only have to send a POST request to the following address: http://smp3server:8080/logfiles/<yourAppID>/<yourAPPCID> . Beside the Authorization and APPCID Header the Content-Type needs to be multipart/form-data with a specified boundary. In the following you can find a sample Request which will upload a client log from app “com.sap.sample.test” and APPCID “TestDevice123” to SMP3.
HTTP POST http://smp3server:8080/logfiles/com.sap.sample.test/TestDevice123 Request Header: Content-Type: multipart/form-data; boundary=smp3logging X-SMP-APPCID: TestDevice123 Authorization: Basic TXlMb2dVcGxvYWRVc2VyOlNvbWVvbmVDaGVja2luZ1RoZVBhc3N3b3JkPw== Request Body: --smp3logging Content-Disposition: form-data; name="log" Content-Type: text/plain charaset=utf-8 This is a test log entry inserted by an HTTP rest request... --smp3logging--
In the following we will try out this Client Log Upload Feature manually:
- Enable the ClientLog for the specifc user/appcid inside SMP3 (Activate “Log Upload”). You can specify here the log level. This value can be asked from the device by sending a GET request to http://smp3server:8080/odata/applications/latest/<appid>/Connections(‘<appcid>’) . This will return the application settings. The vallue “ConnectionLogLevel” will contain the specified value…
- Let’s take a REST client, e.g. Fiddler and perform the POST request (multipart/form-data) like mentioned above
- If it is working you should get a HTTP 200 response which also includes the name of the file which will be created on the filesystem of SMP3 server
- If you now click on the ClientLog Icon beside the specific appcid in SMP3 Management Cockpit you should see the newly created file. For each Client Log Upload you will find here another file.
- Internally (on SMP3 server) the file is stored as a simple text file in folder …\MobilePlatform3\Server\log\clientlogs\appid\appcid
Steps are shown with screenshots in following overview picture:
So try to use this great feature inside your app!