# @elastic/ecs-pino-format

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

Latest version **1.5.0** (published 2023-10-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @elastic/ecs-pino-format
pnpm add @elastic/ecs-pino-format
yarn add @elastic/ecs-pino-format
bun add @elastic/ecs-pino-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.0 |
| Published | 2023-10-31 |
| First published | 2020-03-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 24.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | Tomas Della Vedova |
| Maintainers | 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 | pino, serializer, formatter, elasticsearch, ecs, ecs-logging, elastic, common, schema |

## Links

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

## Dependencies (1)

- [@elastic/ecs-helpers](https://npm.io/package/@elastic/ecs-helpers.md) ^2.1.1

## 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.0 (latest) — 2023-10-31
- 1.4.0 — 2023-10-17
- 1.3.0 — 2021-08-23
- 1.2.0 — 2021-06-28
- 1.1.2 — 2021-05-18
- 1.1.1 — 2021-03-24
- 1.1.0 — 2021-03-19
- 1.0.0 — 2021-02-08
- 0.2.0 — 2021-01-06
- 0.1.0 — 2020-03-30

## README

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

# @elastic/ecs-pino-format

[![npm](https://img.shields.io/npm/v/@elastic/ecs-pino-format.svg)](https://www.npmjs.com/package/@elastic/ecs-pino-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 [pino](https://getpino.io/)
logger compatible with [Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs/current/index.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.

`pino` 6.x, 7.x, and 8.x versions are supported.

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


## Install

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

## Usage

This package will configure Pino's `formatters`, `messageKey` and `timestamp` options.

```js
const { ecsFormat } = require('@elastic/ecs-pino-format')
const pino = require('pino')

const log = pino(ecsFormat(/* options */))
log.info('Hello world')

const child = log.child({ module: 'foo' })
child.warn('From child')
```

Running this will produce log output similar to the following:

```sh
{"log.level":"info","@timestamp":"2023-10-16T18:08:02.601Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"8.10.0","message":"Hello world"}
{"log.level":"warn","@timestamp":"2023-10-16T18:08:02.602Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"8.10.0","module":"foo","message":"From child"}
```

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

## License

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

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