@elastic/ecs-winston-format

中文文档
1.5.3发布于 2024/03/19Apache-2.0TypeScriptCommonJS近 30 天下载 40.9万

用于 Winton 日志的 与 Elastic Community Schema 兼容的文件 .

中文使用文档
文档目录3 节
  1. 安装
  2. 使用量
  3. 许可证

@elastic/ecs-winston-format (英语)

npm test

这个 Node.js 软件包提供了用于 温通 与日志兼容 弹性常见 Schema (ECS) 伐木。 。 。 . 结合 文件节拍 发货人,可以直接将日志发送到弹性搜索和杠杆 Kibana 日志应用程序 在一个地方检查所有日志.

winston 3.x版本得到支持.

请看 ECS Winston 文档。 。 。 .

安装

npm install @elastic/ecs-winston-format

使用量

const winston = require('winston');
const { ecsFormat } = require('@elastic/ecs-winston-format');

const logger = winston.createLogger({
  level: 'info',
  format: ecsFormat(/* options */),
  transports: [
    new winston.transports.Console()
  ]
});

logger.info('hi');
logger.error('oops there is a problem', { foo: 'bar' });

运行此脚本将生成类似于以下的日志输出 :

% node examples/basic.js
{"@timestamp":"2021-01-13T21:32:38.095Z","log.level":"info","message":"hi","ecs":{"version":"8.10.0"}}
{"@timestamp":"2021-01-13T21:32:38.096Z","log.level":"error","message":"oops there is a problem","ecs":{"version":"8.10.0"},"foo":"bar"}

请看 ECS Winston 文档 为了更多.

许可证

该软件根据 Apache 2 许可证。 。 。 .

版本与发布记录

@elastic/ecs-winston-format 共发布 11 个版本,首次发布于 2020/02/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.5.3latest2024/03/192 年前
1.5.22024/01/052 年前
1.5.02023/11/013 年前
1.4.02023/10/183 年前
1.3.12021/09/105 年前
1.3.02021/08/245 年前

关于 @elastic/ecs-winston-format 的常见问题

@elastic/ecs-winston-format 是什么?

用于 Winton 日志的 与 Elastic Community Schema 兼容的文件 .

如何安装 @elastic/ecs-winston-format?

在项目目录运行 npm install @elastic/ecs-winston-format,或使用 pnpm add / yarn add / bun add。

@elastic/ecs-winston-format 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elastic/ecs-winston-format 支持 ESM 还是 CommonJS?

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

@elastic/ecs-winston-format 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@elastic/ecs-winston-format 可以商用吗?

@elastic/ecs-winston-format 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@elastic/ecs-winston-format 的下载量有多少?

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

@elastic/ecs-winston-format 还在维护吗?

最新版本 1.5.3 发布于 2024/03/19(2 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/02/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。