Write JSON logs (PutLogs)
Updated at:
Run CLI commands to write JSON-formatted log data to a specified Logstore.
Prerequisites
Before you begin, make sure that:
Simple Log Service (SLS) is activated. For more information, see Get started with SLS.
The SLS CLI is installed and configured. For more information, see Install and configure the new SLS CLI.
An SLS project and Logstore are created. For more information, see Create a project and Create a Logstore.
Note
The value of the __time__ field must be a Unix timestamp in seconds, specified as a string.
Command syntax
aliyun sls put-json-logs --project=<value> --logstore=<value> --logs <value> [--logs <value> ...] [--topic=<value>] [--source=<value>]Parameters
The following table describes the required and command-specific parameters.
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| --project | String | Yes | aliyun-test-project | The name of the project. |
| --logstore | String | Yes | aliyun-test-logstore | The name of the Logstore. |
| --logs | String | Yes | See the example below | The log content in JSON format. You can specify this parameter multiple times to write multiple log entries. |
| --topic | String | No | app-server | The log topic tag. Use this parameter to categorize logs. |
| --source | String | No | 192.168.1.10 | The log source tag, such as a server IP address. |
For information about global parameters, see Global parameters.
Is this page helpful?