All Products
Search
Document Center

Object Storage Service:How do I enable logging by using OSS SDK for iOS and OSS SDK for Android?

Last Updated:Jul 11, 2023

Overview

This topic describes how to enable logging by using Object Storage Service (OSS) SDK for iOS and OSS SDK for Android.

Details

OSSClient is an OSS client that you can use to manage buckets and objects. Before you use OSS SDKs to initiate a request to OSS, you must first initialize and configure an OSSClient instance. OSS SDKs for mobile platforms may become unavailable in specific regions or during specific periods of time due to the wide variety of use scenarios of mobile devices. To facilitate problem identification, you can enable logging to allow OSS SDKs to record logs in the local client.

Enable logging by using OSS SDK for iOS

// The log style.
//2017/10/25 11:05:43:863  [Debug]: the 17th: <NSThread: 0x7f8099108580>{number = 3, name = (null)}
//2017/10/25 11:05:43:863  [Debug]: the 15th: <NSThread: 0x7f80976052c0>
//2017/10/25 11:05:43:863  [Debug]: ----------TestDebug------------
[OSSLog enableLog];// Use this method to enable logging.
Note
  • Logs are stored in the Caches/OSSLogs directory of the sandbox.

  • You can upload logs to the server to track problems. You can also upload logs to Alibaba Cloud Log Service.

    Enable logging by using OSS SDK for Android

    // The log style.
    // You can call OSSLog.enableLog() to enable logging. This allows you to view logs in the OSS console. 
    // Logs can be written to \OSSLog\logs.csv in a Secure Digital (SD) card of mobile phones. Writing logs to SD cards is disabled by default. 
    // Logs record the request data, returned data, and exception information of OSS operations.
    // For example, a log records information such as the request ID and response headers. The following content provides a sample log. 
    // android_version: 5.1  The Android version.
    // mobile_model: XT1085  The model of the Android mobile phone.
    // network_state: connected  The network connection status.
    //network_type: WIFI  The type of the network connection.
    // The details of the operation.
    //[2017-09-05 16:54:52] - Encounter local execpiton: //java.lang.IllegalArgumentException: The bucket name is invalid. 
    //A bucket name must: 
    //1) be comprised of lower-case characters, numbers or dash(-); 
    //2) start with lower case or numbers; 
    //3) be between 3-63 characters long. 
    //------>end of log
    OSSLog.enableLog(); // Use this method to enable logging

    .

    Note
    • The storage path of logs in the SD cards of Android mobile phones is \OSSLog\logs.csv.

    • You can upload logs to the server to track issues. You can also upload logs to Alibaba Cloud Log Service. For more information, see What is Log Service?

    Applicable scope

    • OSS