All Products
Search
Document Center

Alibaba Cloud CLI:Debug logs

Last Updated:Jul 18, 2024

When you use Alibaba Cloud CLI to call an API operation, you can enable the log output feature to display the log of the request. This helps you analyze whether the response content is correct.

For more information about how to use OSS commands to output logs, see the Use OSS commands to output logs section of this topic.

Configure the environment variable to enable the log output feature

In the CLI, you can set the environment variable DEBUG=sdk to enable the log output feature.

  • Example:

    aliyun ecs DescribeRegions
  • Example output:

    # omitted output
    > POST /?AccessKeyId=AccessKeyId&Action=DescribeRegions&Format=JSON&RegionId=cn-hangzhou&Signature=u9lPKI5Nyw0dIKV5ytJAx6aOTJ0%3D&SignatureMethod=HMAC-SHA1&SignatureNonce=29f426485b2720f6ae0575c900590e28&SignatureType=&SignatureVersion=1.0&Timestamp=2020-05-18T09%3A52%3A42Z&Version=2014-05-26 HTTP/1.1
    > Host: ecs-cn-hangzhou.aliyuncs.com
    > Content-Type: application/x-www-form-urlencoded
    > x-sdk-client: golang/1.0.0
    > User-Agent: AlibabaCloud (darwin; amd64) Golang/1.13.9 Core/0.0.1 Aliyun-CLI/3.0.43
    > x-sdk-invoke-type: common
    > Accept-Encoding: identity
    > x-sdk-core-version: 0.0.1
    >
     Retry Times: 0.
    < HTTP/1.1 200 OK
    < Connection: keep-alive
    < Access-Control-Allow-Origin: *
    < Content-Length: 2238
    < Vary: Accept-Encoding
    < Access-Control-Allow-Methods: POST, GET, OPTIONS
    < Access-Control-Allow-Headers: X-Requested-With, X-Sequence, _aop_secret, _aop_signature
    < Access-Control-Max-Age: 172800
    < Date: Mon, 18 May 2020 09:52:43 GMT
    < Content-Type: application/json;charset=utf-8
    <
    # omitted output

Use OSS commands to output logs

When you use OSS commands to output logs, you can use the --loglevel option to specify the log level.

Valid values:

  • By default, this option is empty. No log is output.

  • info: informational log.

  • debug: detailed log.

The log is output to a file. The file path is displayed in the CLI. Example:

aliyun oss ls --loglevel info
log file is /Users/user/Documents/ossutil.log
# omitted output