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 iOS for detailed information about logging and tracing.

Procedure

  1. Initialize the logger, define a log level setting, and log messages:
    // Initializing logManager
    _logger = [[SAPSupportabilityFacade sharedManager] getClientLogger:@"com.sap.logging.all"];
    
    // Logging a message
    [_logger logInfo:@"Log something”];
    
  2. Retrieve logs:
    NSArray* logData = [[[SAPSupportabilityFacade sharedManager] getClientLogManager] 
    getLogEntriesForLogger: @"com.sap.logging.all" withLevel:AllClientLogLevel];
  3. Upload the client log to SAP Mobile Platform Server:
    SupportabilityUploader* uploader = [[SupportabilityUploader alloc] 
    initWithHttpConversationManager:self.conversationManager urlRequest:request];
    [[[SAPSupportabilityFacade sharedManager] getClientLogManager] uploadClientLogs:uploader completion:^(NSError* error) {
            if (error == nil) {
                NSLog(@"upload succeeded");
            } else {
                NSLog(@"upload failed: %@", [error description]);
    		  }
        }];