# @pager/logger

> Logging library

Latest version **7.12.0** (published 2026-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pager/logger
pnpm add @pager/logger
yarn add @pager/logger
bun add @pager/logger
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.12.0 |
| Published | 2026-03-18 |
| First published | 2016-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.9 |
| Dependencies | 2 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aftab-alam-khan, peter-vizi-pager, otonyu, mark.ferris, exequiel-sanoner, ahmed_vuk, ebrcaninovic, circle-pager, sa-pagerinc-automation, shankyjs, ryshah1207, blaine-pager, jmelero.pager, batroukhhamza, i-am-ian, joan.semander, jiggyjigsj, juancabuhe, juandara22, juan.lacoste.pager, luciabrumnich.pager, mzelem, brianseidl_pager, thebigkatona, kyleherrmann, anthonyhancock, sharmila8908, sapnamate, petermai-pager, catherinekimyj-pager, justin_pennington, max-d-lucas, richibbs, moui, meerabjorn-onlife, amalajose-onlife, adimoff, craig-parker-pager, nachocasas, ewise_onlife, tjharke13, lgenzelis, epsanchezma, roybay04, kuryaki, lance_lyons, ankita.banait, alena.b.pager, duvanmonsa, sai.davuluri, saretovic, marcie.price, lancehamiltonolh, guessed, matthew_moss, guido.rubin, pabrou, mikelockz, azra.dedic, tedjanton, afahrenholtzph, bezrabotni, pcfleischer, jon-dosmann-pager, atanovic, peraltafederico, danielshoun, marissapennington-pagerhealth, dmsq22, jeremiahbowen, chrisft25, edzebo, shashi-ph, rinkeshph, pager-juampi, vbacalov, artsenius, ijuani, pagervineesh, christopher.cleary, adamolsentech, fauricio-pager |
| Keywords | logs |

## Links

- npm: https://www.npmjs.com/package/@pager/logger
- Repository: https://github.com/pagerinc/logger
- Homepage: https://github.com/pagerinc/logger#readme
- Issues: https://github.com/pagerinc/logger/issues
- npm.io page: https://npm.io/package/@pager/logger

## Dependencies (2)

- [pino](https://npm.io/package/pino.md) 10.x
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.2.2

## 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

- 7.12.0 (latest) — 2026-03-18
- 7.12.0-alpha.4 (alpha) — 2026-03-11
- 6.1.0-beta.0 (beta) — 2023-01-06
- 7.12.0-alpha.3 — 2026-03-04
- 7.12.0-alpha.2 — 2026-03-03
- 7.12.0-alpha.1 — 2026-03-03
- 7.12.0-alpha.0 — 2026-03-03
- 7.11.1 — 2025-10-03
- 7.11.0 — 2025-10-03
- 7.10.0 — 2025-09-26
- 7.9.6-alpha.0 — 2025-09-11
- 7.9.5 — 2025-04-30
- 7.9.4 — 2025-04-29
- 7.9.3 — 2025-04-24
- 7.9.2 — 2025-04-24
- … 101 more at https://npm.io/package/@pager/logger/versions

## README

# @pager/logger

Structured logging for your verbose projects. Provides a [pino](https://github.com/pinojs/pino) logger with standard
Pager defaults and redactions.

As of [v7.0.0](https://github.com/pagerinc/logger/releases/tag/v7.0.0), no hapi plugin is exposed in this library.
Hapi-based projects should use [@pager/hapi-logger](https://github.com/pagerinc/hapi-logger) instead of this library.
For an explanation of the split, see [ADR-0015](https://pagerinc.atlassian.net/wiki/spaces/EN/pages/3008200714/ADR-0015).

## Basic usage

Provides a logger with standardized formatting and redaction configuration. For more details on how to work with Pino, take a look at [its documentation](https://github.com/pinojs/pino) or see [configuration](#Configuration) below for the setup details.

> [!IMPORTANT]  
> Not for use in [hapi](https://hapi.dev/) projects, if your project uses hapi use
> [@pager/hapi-logger](https://github.com/pagerinc/hapi-logger) instead of this library

### Redacting

This library has been set up with an array of standard redactions based on current usage. Each app should explicitly append and detail all potential leaks. There are no wildcard defaults because there are large associated performance issues with wildcards, particularly intermediate wildcards. Please do your part in log security to ensure no PHI or secrets are leaked into the logs; defaults provided in the code are append only.

## Environment

| Name | Default | Description |
|------|---------|-------------|
| LOG_LEVEL | `info` | Lowest level to log in this order: `trace`, `debug`, `info`, `warn`, `error`, `fatal` |
| LOG_ERROR_THRESHOLD | `error` | Lowest error to send to error transport |
| LOG_PRETTY_PRINT | _none_ | Set to `1` to enable pretty print - this is *not* json and follows the configuration for [prettyPrint docs](https://github.com/pinojs/pino-pretty#pino-pretty) |


### pino options
Pino default overrides per [Pino's documentation](https://github.com/pinojs/pino/blob/master/docs/api.md#options-object).

```javascript
{
  "level": "warn", // any pino default option overrides
  "redact": ['redactKey']
}
```

### pino (Object)
Pino configuration object per [Pino's documentation](https://github.com/pinojs/pino/blob/master/docs/api.md#options-object)

### instance (pino object)
Already configured pino object

## Installation and Usage

```javascript
// injecting a logger is best practice for most cases, defaulting to singleton is acceptable
const Logger = require('@pager/logger');

module.exports = (logger = Logger) => {

    Logger.info('Worker log');

    // .. worker works ...
    try {
        // do work
    }
    catch (err) {
        logger.error(err);
    }
};
```

### Error handling

Under the hood we are using pino's [default error serializer](https://github.com/pinojs/pino-std-serializers/blob/master/lib/err.js). This means it will add extra keys on the error object if present, and are not already used by one of pino's preset keys (e.g. `data`, `message`, `type`, etc.).

For example, see the custom field `context` within the error and it's expected log output:

```javascript

const entity = { id: '6025827b568bb78e64b83ba2' };
const error = new Error('my error title');
error.context = { entityId: entity.id };
Logger.error(error);
/* Prints something like:
  {
    "level": 50,
    "time": 1613070971891,
    "pid": 58541,
    "hostname": "hostMBP",
    "context": {
      "entityId": "6025827b568bb78e64b83ba2"
    },
    "stack": "Error: my error title\n    at /projects/edge-api-cc/test/custom-error.js:19:23\n    at Immediate._onImmediate (/projects/edge-api-cc/node_modules/@hapi/lab/lib/runner.js:661:35)\n    at processImmediate (internal/timers.js:461:21)",
    "type": "Error",
    "data": "my error title"
  }
*/
```

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