# @elastic/ecs-winston-format

> A formatter for the winston logger compatible with Elastic Common Schema.

Latest version **1.5.3** (published 2024-03-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @elastic/ecs-winston-format
pnpm add @elastic/ecs-winston-format
yarn add @elastic/ecs-winston-format
bun add @elastic/ecs-winston-format
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.5.3 |
| Published | 2024-03-18 |
| First published | 2020-02-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 28.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | Tomas Della Vedova |
| Maintainers | asnyder-elastic, lgestc, patryk.kopycinski, banerjeesoham004, legrego, bradtimmerman, devcorpio, yan.savitski, jeramysoucy, tkajtoch, johnwcambra, colleen.mcginnis, scottybollinger, kyrspl, phoey1, verogo, breehall, trevorpierce, glitteringkatie, jen-huang, delvedor, lukasolson, ccowan, jbudz, thomasneirynck, weltenwort, pugnascotia, zinckiwi, brandon.kobel, nreese, mgreau, jonahbull, jarpy, leathekd, lukeelmers, ddillinger, joshdover, jasonstoltz, bamieh, markov00, joshmock, vignesh.shanmugam, watson, rhodesjason, jmlrt, mattkime, constancecchen, afoucret, nickpeihl, axw, mistic, elasticmachine, gtback, pickypg, trentm, andrewvc-elastic, jorge.sanz, stratoula, nkammah, streamich, nickofthyme, chloeruka |
| Keywords | winston, serializer, formatter, elasticsearch, ecs, ecs-logging, elastic, common, schema |

## Links

- npm: https://www.npmjs.com/package/@elastic/ecs-winston-format
- Repository: https://github.com/elastic/ecs-logging-nodejs
- Homepage: https://github.com/elastic/ecs-logging-nodejs/blob/main/packages/ecs-winston-format/README.md
- Issues: https://github.com/elastic/ecs-logging-nodejs/issues
- npm.io page: https://npm.io/package/@elastic/ecs-winston-format

## Dependencies (3)

- [triple-beam](https://npm.io/package/triple-beam.md) >=1.1.0
- [@elastic/ecs-helpers](https://npm.io/package/@elastic/ecs-helpers.md) ^2.1.1
- [safe-stable-stringify](https://npm.io/package/safe-stable-stringify.md) ^2.4.3

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.5.3 (latest) — 2024-03-18
- 1.5.2 — 2024-01-04
- 1.5.0 — 2023-10-31
- 1.4.0 — 2023-10-17
- 1.3.1 — 2021-09-09
- 1.3.0 — 2021-08-23
- 1.1.0 — 2021-03-19
- 1.0.0 — 2021-02-08
- 0.3.0 — 2021-01-06
- 0.2.0 — 2020-03-16
- 0.1.0 — 2020-02-11

## README

<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png">

# @elastic/ecs-winston-format

[![npm](https://img.shields.io/npm/v/@elastic/ecs-winston-format.svg)](https://www.npmjs.com/package/@elastic/ecs-winston-format)
[![test](https://github.com/elastic/ecs-logging-nodejs/actions/workflows/test.yml/badge.svg)](https://github.com/elastic/ecs-logging-nodejs/actions/workflows/test.yml)

This Node.js package provides a formatter for the
[winston](https://github.com/winstonjs/winston) logger compatible with
[Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs-logging/overview/master/intro.html).
In combination with the [filebeat](https://www.elastic.co/products/beats/filebeat)
shipper, you can send your logs directly to Elasticsearch and leverage
[Kibana's Logs app](https://www.elastic.co/guide/en/observability/current/monitor-logs.html)
to inspect all logs in one single place.

`winston` 3.x versions are supported.

Please see the [Node.js ECS winston documentation](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/winston.html).


## Install

```sh
npm install @elastic/ecs-winston-format
```

## Usage

```js
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' });
```

Running this script will produce log output similar to the following:

```sh
% 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"}
```

Please see the [Node.js ECS winston documentation](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/winston.html) for more.

## License

This software is licensed under the [Apache 2 license](./LICENSE).

---
_Source: https://npm.io/package/@elastic/ecs-winston-format · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
