Developers can use Software Development Kits (SDKs) for languages such as .NET Core, Java, Python, PHP, Node.js, C, Go, iOS, Android, and C++ to collect, query, and analyze logs.
Usage notes
The implementation details of the Simple Log Service SDK vary by programming language. However, all SDKs are wrappers for the Simple Log Service API and provide similar features. These features include the following:
Provides a unified wrapper for Simple Log Service API operations. You do not need to handle the details of building API requests or parsing responses. The operations are similar across different languages, which makes it easy to switch between them. For more information, see API specifications.
Implements the digital signature logic for the Simple Log Service API. This simplifies the use of the API because you do not need to handle the signature details. For more information, see Request signatures.
Encapsulates logs in the Protocol Buffer format. You do not need to handle the specific details of the Protocol Buffer format when you write logs. For more information, see Protocol Buffer format.
Implements the compression methods defined in the Simple Log Service API. You do not need to handle the compression details. The SDKs for some languages support writing logs in compressed mode. This mode is enabled by default.
Provides a unified fault handling mechanism. This lets you handle request exceptions in a way that is familiar to the programming language. For more information, see Fault handling mechanism.
All SDKs currently support only synchronous requests.
SDK list
The following table lists the reference documents and GitHub source code for the Simple Log Service SDKs for different languages.
Simple Log Service imposes reasonable limits on basic resources, such as the number of projects, Logstores, shards, and the size of a LogItem. Before you use an SDK, review the limits documentation to understand the usage limits for basic resources. For more information, see Limits on basic resources.
After you use an SDK to collect and send logs to Simple Log Service, you must configure indexes for the logs. This lets you query and analyze logs, perform data transformation, and run other operations. For more information, see Create an index and Quick guide to query and analysis.
SDK language | Reference document | GitHub source code |
Java | ||
.NET Core | ||
PHP | ||
Python | ||
Node.js | ||
C | ||
Go | ||
iOS | ||
Android | ||
C++ | ||
HarmonyOS |
Example call
For an example call, see Call the ListProject operation of Simple Log Service using the Python SDK.
FAQ
What features do Simple Log Service SDKs support?
Simple Log Service SDKs support most features of Simple Log Service, including log collection, index creation, query and analysis, data transformation, log consumption, log delivery management, alerting, and scheduled SQL jobs. If you find an unsupported feature when you debug an SDK, upgrade the SDK to the latest version and retry. If the feature is still unsupported, check for future SDK updates.
What is the basic procedure for using a Simple Log Service SDK?
Simple Log Service SDKs provide end-to-end log management. The procedure for using an SDK is similar to the procedure for using the console. The basic procedure is as follows:
Activate Simple Log Service.
Obtain an AccessKey pair.
Create a project and a Logstore.
Collect logs and store them in the Logstore.
Create indexes for the logs.
Query and analyze the logs, and visualize the results.
Perform operations such as data transformation, delivery, and alerting on the log data.
Simple Log Service provides a console to simplify these operations. For more information, see Simple Log Service Quick Start.
How do I handle common faults that occur during SDK debugging?
Simple Log Service SDKs provide fault handling logic. The faults that may occur when you use an SDK can be divided into the following categories:
Exceptions that are returned by Simple Log Service. This type of exceptions are handled by Simple Log Service SDK. For more information about this type of exceptions, see the description and error codes of each API operation. For more information about the error codes, see Error codes.
Network exceptions that occur when you use Simple Log Service SDK to send requests. This type of exceptions include network disconnection and server response timeout.
Exceptions that are generated by Simple Log Service SDK and related to platforms and programming languages, such as, memory overflow.
For more information, see Fault handling.
When you use a Simple Log Service SDK, you may encounter various faults related to log collection, indexing, query and analysis, and transformation. You can refer to the Simple Log Service FAQ for solutions. For more information, see FAQ.
Are there limits on using Simple Log Service SDKs?
Simple Log Service imposes reasonable limits on basic resources, such as the number of projects, Logstores, shards, and the size of a LogItem. Before you use an SDK, review the limits documentation to understand the usage limits for basic resources. For more information, see Limits on basic resources.
Are there code example documents for the SDKs?
Simple Log Service provides documentation with code examples for common operations. You can find these examples in the reference documents for each SDK.
Simple Log Service Java SDK:
Simple Log Service Python SDK:
Simple Log Service SDKs for various languages:
For more source code, see the Alibaba Cloud Log source code library on GitHub.
References
Simple Log Service SDK debugging platform
The Alibaba Cloud OpenAPI Developer Portal provides debugging tools, SDKs, examples, and supporting documentation. You can use the OpenAPI Developer Portal to quickly debug Simple Log Service API operations without manually encapsulating requests or performing signing operations. For more information, see OpenAPI Developer Portal.
Command-line interface (CLI)
Simple Log Service provides a command-line interface (CLI) for automated configuration. For more information, see Command-line interface (CLI).
Billing
Using the SDKs, the OpenAPI Developer Portal, or the Simple Log Service CLI incurs the same fees as using the console. For more information, see Billing overview.