Fork me on GitHub

Configure CLI


There’re ceratin options need to configure to make it more convenient to use CLI.

CLI options

CLI options include:

Configure AK and Endpoint

There’re three ways to configure the access key and endpoint and they’re prioritized as below:

  • Parameters
> aliyunlog log create_project ..... --access-id=<value> --access-key=<value> --region-endpoint=<value>

Note: Any sub command support such way to overwrite the AK setings in later ways (env or config file) for the specific operations.

  • Environment Variables
  • Local configuration file

You could store them at ~/.aliyunlogcli, the default section name is main


Enable Https Connection

When configuring endpoint with prefix https://, the connection between CLI and Log service will be secured. Or else, it will use http by default.

Modify the configuration file

Use the command “configure” to modify the configuration file:

> aliyunlog configure access_id access_key

Multiple Account

  1. Store multiple accounts for some use cases (e.g. test, multiple region operations)
> aliyunlog configure access_id1 access_key1
> aliyunlog configure access_id2 access_key2 test

AK is stored as:



Refer to here to know a simpler way to configure multiple accounts in config file.

  1. Use specific account

Any subcommand could use global opton --client-name=<value> to use specific configured account. e.g:

> aliyunlog log create_project ..... --client-name=test

It will use test to create the project.

  1. Other Case

In some case, we need to operate cross regions, e.g.

> aliyunlog log copy_project --from_project="p1" --to_project="p1" --to_client=test

It will use account main to copy project p1 in its region to another region under account test

Default account

As mentions previously, the name of default account is main, in specific case, it’s necessary to swith to another account (in different region). This could be archvied by using option --default-client:

aliyunlog configure --default-client=beijing

This command will switch default account to the one beijing.

Format output

JSON Format

Output is in json format normally, which is printed in one line in console. In some cases, it’s useful to show them in pretty format. You could use option --format-output=json in each command for this:

aliyunlog log get_log....  --format-output=json

But if you want to make it a default behavior, configure it directly:

aliyunlog log configure --format-output=json

Not escape Non-ANSI

By default, for non-ANSI characters, it will escape it. If you want to view the raw string, you could add a no_escape to format of output:

aliyunlog log get_log....  --format-output=json,no_escape

It could be no_escape or combine with other value in format-output with ,

And if you want to make it a default behavior, configure it directly:

aliyunlog log configure --format-output=json,no_escape