Files
boc/services/frilans-payout/node_modules/pino/docs/asynchronous.md
T
Bernt 1a12fb870b dev-api: add developer portal, OpenAPI spec, and Flatenbadet case study
- New /developers/ page with API docs, SDKs, pricing, use cases
- OpenAPI 3.0 spec for Orders, Missions, Photos, Analytics
- Case study: Glasskiosken i Flatenbadet — complete ROI analysis
- Updated /order/ with recurring missions and frequency dropdown
2026-07-14 15:27:33 +00:00

1.5 KiB

Asynchronous Logging

Asynchronous logging enables the minimum overhead of Pino. Asynchronous logging works by buffering log messages and writing them in larger chunks.

const pino = require('pino')
const logger = pino(pino.destination({
  dest: './my-file', // omit for stdout
  minLength: 4096, // Buffer before writing
  sync: false // Asynchronous logging
}))

It's always possible to turn on synchronous logging by passing sync: true. In this mode of operation, log messages are directly written to the output stream as the messages are generated with a blocking operation.

AWS Lambda

Asynchronous logging is disabled by default on AWS Lambda or any other environment that modifies process.stdout. If forcefully turned on, we recommend calling dest.flushSync() at the end of each function execution to avoid losing data.

Caveats

Asynchronous logging has a couple of important caveats:

  • As opposed to the synchronous mode, there is not a one-to-one relationship between calls to logging methods (e.g. logger.info) and writes to a log file
  • There is a possibility of the most recently buffered log messages being lost in case of a system failure, e.g. a power cut.

See also: