Developer

Logging Operations

Log various application events, by specifying a log level, then upload the client log to SAP Mobile Platform Server for analysis.

Prerequisites

Define client log and trace policies in the SAP Mobile Platform Server Management Cockpit or HANA Cloud Platform Mobile Services Cockpit. For detailed information see SAP Mobile Platform http://help.sap.com/mobile or SAP HANA Cloud Platform Mobile Platform https://help.hana.ondemand.com/hana_cloud_platform_mobile_services/frameset.htm. See Managing Application Logs and Traces.

Context

See Supportability for Android for detailed information about logging and tracing.

Procedure

  1. Initialize the logger, define a log level setting, and log messages:
    // Initializing logManager and sets the log level
    ClientLogger logger = Supportability.getInstance().getClientLogger(context, OnlineODataStore.class.getCanonicalName());
    
    Supportability.getInstance().getClientLogManager(context).setLogLevel(ClientLogLevel.DEBUG);
    
    logger.logDebug("log message");
    
    
  2. Retrieve logs:
    List<ClientLogEntry> entries = logMan.getLogEntries();
  3. Upload the client log to SAP Mobile Platform Server:
    SupportabilityUploaderImpl uploader = new SupportabilityUploaderImpl(conv, context);
    logMan.uploadClientLogs(uploader, new UploadListener() {
    
    public void onUploadSuccess() {
       	makeToastText("Log Upload Successful");
       }
    
       public void onUploadFailure(UploadResult result) {
       	String msg = "Log Upload Failed: " + result.getResponseStatusCode() + ", " + result.getHint();
            makeToastText(msg);
       }
    });