OSSClient is an OSS client used to manage buckets and objects. Before you use OSS SDKs to initiate a request to OSS, you must 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. OSS SDK for iOS and OSS SDK for Android include a built-in logging feature that records request data, response data, and exception details on the device. Enable logging to diagnose connectivity failures or unexpected errors in mobile environments.
Enable logging on iOS
Call [OSSLog enableLog] during app initialization:
// Log format example:
// 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];Logs are written to the Caches/OSSLogs directory in the app sandbox.
Enable logging on Android
Call OSSLog.enableLog() during app initialization. This allows you to view logs in the OSS console.
// Log format example:
// android_version: 5.1
// mobile_model: XT1085
// network_state: connected
// network_type: WIFI
// [2017-09-05 16:54:52] - Encounter local exception:
// 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();Each log entry includes the Android version, device model, network connection status, network type, request data, response data, and exception details.
Logs can optionally be written to \OSSLog\logs.csv on a Secure Digital (SD) card. SD card logging is disabled by default.
Upload logs for analysis
To analyze logs remotely, upload them to a server or to Alibaba Cloud Log Service.