Quick start

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
All documents
menu
No results found, please re-enter

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
  • Document center
  • arrow
  • BLS
  • arrow
  • Development Guide
  • arrow
  • SDK Reference
  • arrow
  • iOS SDK
  • arrow
  • Quick start
Table of contents on this page
  • Introduction
  • Environmental requirements
  • Install the SDK Package
  • Installation steps
  • SDK directory structure
  • Use of SDK
  • Example 1: upload logs
  • Example 2: create logstores

Quick start

Updated at:2025-11-03

Introduction

This document mainly introduces the installation and use of Baidu AI Cloud Log Service iOS SDK.

This document assumes that you have enabled the Baidu AI Cloud log service.

If you haven't enabled or don't understand the log service, please log on to the Log Service Product Homepage for more help.

Environmental requirements

  • iOS system version: 9.0 and above
  • It is required to register a Baidu AI Cloud user account and open the log service

Install the SDK Package

Installation steps

  1. Find the Baidu log service from the client SDK list of Baidu AI Cloud Developer Center, download the SDK compressed package, and decompress it to obtainBDLogServiceSDK.framework.
  2. As needed, copy the framework into the Xcode project directory, such as the lib directory.
  3. Right-click in Xcode, select "Add Files to "Your Project"", and import the copied framework.

SDK directory structure

Plain Text
1|_BDLogServiceSDK.framework                   // BLS SDK
2| |____Headers
3 |   |____BDLogServiceSDK.h                    // BLS header file description
4 |   |____BDLogServiceConfig.h                 // BLS configuration
5 |   |____BDLogServiceClient.h                 // BLS client
6 |   |____BDLogServiceClient+LogStore.h        // BLS logstore API
7 |   |____BDLogServiceClient+LogStream.h       // BLS logstream API
8 |   |____BDLogServiceClient+LogRecord.h       // BLS read/write log API
9 |   |____BDLogServiceClient+FastQuery.h       //BLS fast query API
10 |   |____BDLogServiceClient+Index.h           // BLS index API
11 |   |____BDLogServiceClient+LogShipper.h      // BLS logshipper API
12 |   |____LogStore.h                           // BLS logstore model
13 |   |____LogStream.h                          // BLS logstream model
14 |   |____LogRecord.h                          // BLS logrecord model
15 |   |____FastQuery.h                          // BLS fast query Model
16 |   |____LogStoreIndex.h                      // BLS logstore index model
17 |   |____LogShipper.h                         // BLS logshipper model
18 |   |____BDLogServiceConstants.h              // BLS constant definition
19 |   |____BDCloudSigner.h                      // BLS AK, SK signature

Use of SDK

Example 1: upload logs

  1. Initialize ak/sk, endpoint, and create a BDLogServiceClient object. (Available endpoints can be viewed in [API Reference-Service Domain Name](BLS/Development Guide/API Reference/Service domain.md))
ObjectiveC
1//Initialize AK SK
2NSString *ak = @"<access key>";    
3NSString *sk = @"<secret key>";
4NSString *endpoint = @"<endpoint>";
5BDLogServiceConfig *config = [[BDLogServiceConfig alloc] initWithEndpoint:endpoint accessKey:ak secretKey:sk];
6BDLogServiceClient *client = [[BDLogServiceClient alloc] initWithConfig: config];
  1. Call the pushLogRecord API to upload logs

    Log records can be in TEXT or JSON format. For TEXT logs, the records are not processed; for JSON logs, only the first-level JSON fields are automatically detected (nested fields are not supported at this time).

    To upload both the processed specific fields and the raw log text, use the JSON format. Include the raw log text in JSON with "@raw" as the key and the raw log text as the value. While processing "@raw," BLS will treat its content as the raw log text.

    For example:

    • TEXT type
    ObjectiveC
    1 LogRecord *logRecord = [[LogRecord alloc] initWithMessage: @"this is log."]
    • JSON type
    ObjectiveC
    1 LogRecord *logRecord = [[LogRecord alloc] initWithMessage: @"{\"level\":\"info\", \"status\": 200, \"cost\": 304.87}"]
    • JSON type, including the raw log text
    ObjectiveC
    1 LogRecord *logRecord = [[LogRecord alloc] initWithMessage: @"{\"@raw\":\"info 200 304.87ms this is log.\", \"level\":\"info\", \"status\": 200, \"cost\": 304.87}"]
ObjectiveC
1//Configuration parameters, request interface
2NSString *logStoreName = @"<custom name>";
3NSString *logStreamName = @"<custom name>";
4NSInteger time = (NSInteger)([NSDate date].timeIntervalSince1970 * 1000); //Log timestamp: It cannot exceed current timestamp, in milliseconds
5NSString *type = @"TEXT"; //Log record format: It supports JSON/TEXT, defaulting to TEXT. Refer to the log record format description above. All log records in one upload request must be of the same format
6NSArray *logRecords = @[
7    @{
8@"message":@"<Log content: It can be text or JSON string. Refer to the log record format description above>",
9        @"timestamp":[NSNumber numberWithInteger:time]
10    },
11    @{
12@"message": @"<Log content: It can be text or JSON string. Refer to the log record format description above>",
13        @"timestamp": [NSNumber numberWithInteger:time]
14    }
15]; //Log records
16__weak typeof(self) weakSelf = self;  
17[client pushLogRecordWithLogStoreName:logStoreName   logStreamName:logStreamName type:type logRecords:logRecords completion:^(NSDictionary * _Nonnull resultDic, NSError * _Nonnull error) {       
18//resultDic returns the data result from the server
19if(error){ //Failure
20        NSLog(@"%@ %@", resultDic[@"message"], error);
21} else { //Success
22NSLog(@"The log record is pushed successfully");
23    }
24}];

Example 2: create logstores

  1. Initialize ak/sk, endpoint, and create a BDLogServiceClient object. (Available endpoints can be viewed in [API Reference-Service Domain Name](BLS/Development Guide/API Reference/Service domain.md))
ObjectiveC
1//Initialize AK SK
2NSString *ak = @"<access key>";    
3NSString *sk = @"<secret key>";
4NSString *endpoint = @"<endpoint>";
5BDLogServiceConfig *config = [[BDLogServiceConfig alloc] initWithEndpoint:endpoint accessKey:ak secretKey:sk];
6BDLogServiceClient *client = [[BDLogServiceClient alloc] initWithConfig: config];
  1. Call the createLogStore API to create logstores
ObjectiveC
1//Configuration parameters, request interface
2NSString *logStoreName = @"<custom name>";
3NSString *retention =  @"10";  // Lease period of logstore, unit: days
4__weak typeof(self) weakSelf = self;  
5[client createLogStoreWithLogStoreName:logStoreName   retention:[retention intValue] completion:^(NSDictionary * _Nonnull resultDic, NSError * _Nonnull error) {
6//resultDic returns the data result from the server
7if(error){ //Failure
8        NSLog(@"%@ %@", resultDic[@"message"], error);
9} else { //Success
10NSLog(@"LogStore created successfully");
11    }
12}];

The calling process of other service APIs is similar to the examples. For the specific usage of API used by SDK, please refer to: [API Reference-Overview](BLS/Development Guide/API Reference/Overview.md)

Previous
Overview
Next
Version Release Records