# @4lch4/logger

> A small utility for logging to console within NodeJS/TypeScript applications.

Latest version **2.2.0** (published 2026-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @4lch4/logger
pnpm add @4lch4/logger
yarn add @4lch4/logger
bun add @4lch4/logger
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-10-21 |
| First published | 2021-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | 4lch4 |
| Maintainers | alcha, 4lch4-ci |
| Keywords | util, logger, log, logging, stdout |

## Links

- npm: https://www.npmjs.com/package/@4lch4/logger
- Repository: https://github.com/4lch4/Logger
- Issues: https://github.com/4lch4/Logger/issues
- npm.io page: https://npm.io/package/@4lch4/logger

## Dependencies (2)

- [winston](https://npm.io/package/winston.md) ^3.19.0
- [@axiomhq/winston](https://npm.io/package/@axiomhq/winston.md) ^2.0.0

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

- 2.2.0 (latest) — 2026-10-21
- 2.1.0 — 2023-11-15
- 2.0.0 — 2023-07-24
- 2.0.0-pre.1 — 2023-07-23
- 2.0.0-pre.0 — 2023-07-23
- 1.11.0 — 2022-08-25
- 1.9.2 — 2022-06-17
- 1.9.1 — 2022-06-17
- 1.9.0 — 2022-06-17
- 1.8.4 — 2022-06-17
- 1.8.3 — 2022-06-17
- 1.8.2 — 2022-06-17
- 1.8.1 — 2022-06-17
- 1.8.0 — 2022-06-17
- 1.7.4 — 2021-11-01
- … 17 more at https://npm.io/package/@4lch4/logger/versions

## README

# @4lch4/logger

A small Winston-based logger for Node.js that writes to the console and, optionally, to
[Axiom](https://axiom.co).

## Requirements

Node.js >= 22.

## Installation

```shell
npm install @4lch4/logger
```

## Usage

The package exports a single, shared logger instance:

```typescript
import { logger } from '@4lch4/logger'

logger.info('Hello, world!')
logger.debug('Some extra detail')
logger.warn('Something looks off')
logger.error('Something broke')
logger.success('It worked')
```

The logger always writes to the console and, when the Axiom environment variables are set, also
sends entries to Axiom.

## Log levels

It uses the npm levels (`error`, `warn`, `info`, `http`, `verbose`, `debug`, `silly`) plus a
custom `success` level. `success` has the highest priority, so it is always logged. Console
colors: `success` is green, `info` is cyan, and the rest use Winston's defaults.

## Environment variables

- `LOG_LEVEL` — level to log at. Takes precedence over `NODE_ENV`.
- `NODE_ENV` — when `production`, the default level is `info`; otherwise it is `debug`.
- `LOG_SERVICE`, `API_NAME`, `APP_NAME` — service name added to every entry, checked in that
  order.
- `HOSTNAME` — hostname added to every entry; defaults to `localhost`.
- `AXIOM_DATASET`, `AXIOM_TOKEN` — when both are set, entries are also sent to Axiom.
- `AXIOM_ORG_ID` — Axiom org ID; only needed when using a personal token.

Every entry also includes `service`, `nodeEnv` (default `development`), `hostname`, `arch` and
`platform` metadata.

## Exports

- `logger` — the shared logger instance.
- `Logger` — the logger type, which adds `success` to Winston's `Logger`.
- `ConsoleTransport` — the configured Winston console transport.
- `AxiomTransport(dataset, token, orgId?)` — creates a Winston transport that logs to Axiom.

## License

MIT

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