@alicloud/log

中文文档
1.2.6发布于 2025/12/16MITCommonJS近 30 天下载 6.6万

Aliyun Log Service Node.js SDK

原始使用文档
文档目录3 节
  1. Init Client
  2. Use permanent accessKey
  3. Use Credentials Provider

Integration Test

  1. Create a test project
  2. Create two test stores under that project, one with index configured
  • The first one (without log index configured) will be used to test index CRUD
  • The second one (with log index configured) will be used to test log retrieval
  1. Run
ACCESS_KEY_ID=<key> ACCESS_KEY_SECRET=<secret> TEST_PROJECT=<project you have created> TEST_STORE=<test store without index> TEST_STORE2=<test store with index> make test

Init Client

Use permanent accessKey

use region

const client = new Client({
  accessKeyId: "your_access_key_id",
  accessKeySecret: "your_access_key_secret",
  region: 'cn-hangzhou'
});

or use endpoint

const client = new Client({
  accessKeyId: "your_access_key_id",
  accessKeySecret: "your_access_key_secret",
  endpoint: 'cn-hangzhou.log.aliyuncs.com'
});

Use Credentials Provider

The CredentialsProvider offers a more convenient and secure way to obtain credentials from external sources. You can retrieve these credentials from your server or other Alibaba Cloud services, and rotate them on a regular basis.

const yourCredentialsProvider = new YourCredentialsProvider();
const client = new Client({
  credentialsProvider: yourCredentialsProvider,
  region: 'cn-hangzhou'
});

The credentialsProvider implemented by yourself must be an object that has a property named getCredentials, and getCredentials is a callable function/method that returns a credentials object.

The returned credentials object from getCredentials must not be null or undefined, and has properties named accessKeyId, accessKeySecret and securityToken.

Here is a simple example of a credentialsProvider:

class YourCredentialsProvider {
  constructor() {
    this.credentials = {
      accessKeyId: "your_access_key_id",
      accessKeySecret: "your_access_key_secret",
      securityToken: "your_security_token"
    };
  }
  // The method getCredentials is called by client to get credentials for signing and authentication.
  // Caching and refreshing logic is required in your implementation for performance.
  async getCredentials() {
    return this.credentials;
  }
}

版本与发布记录

@alicloud/log 共发布 10 个版本,首次发布于 2017/08/31;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.2.6latest2025/12/1610 个月前
1.2.52025/03/051.7 年前
1.2.42025/02/241.7 年前
1.2.32024/12/021.9 年前
1.2.22024/11/291.9 年前
1.2.12020/04/036 年前

关于 @alicloud/log 的常见问题

@alicloud/log 是什么?

Aliyun Log Service Node.js SDK

如何安装 @alicloud/log?

在项目目录运行 npm install @alicloud/log,或使用 pnpm add / yarn add / bun add。

@alicloud/log 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/alicloud__log 是否存在。

@alicloud/log 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@alicloud/log 可以商用吗?

@alicloud/log 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alicloud/log 的下载量有多少?

根据 npm 官方下载统计,@alicloud/log 在 2026/10/06 – 2026/11/04 这 30 天内被下载 65,940 次,日均约 2,198 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alicloud/log 还在维护吗?

最新版本 1.2.6 发布于 2025/12/16(10 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 1 个;首次发布于 2017/08/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。