pinojs/pino

Recommended setup for production

Open

#1491 opened on Jul 10, 2022

View on GitHub
 (4 comments) (12 reactions) (0 assignees)JavaScript (13,157 stars) (839 forks)batch import
documentationgood first issue

Description

The documentation contains a mixed use of pino.transport, pino.destination, pino.multistream, and Pino created without arguments. Legacy vs Pino v7+ transports is also confusing.

What's the recommended setup for production? Production = least overhead, best performance, logging to stdout

My first guess would be

const logger = pino(pino.destination());

After reading the documentation, I've found a paragraph:

The difference between using the pino/file transport builtin and using pino.destination is that pino.destination runs in the main thread, whereas pino/file sets up pino.destination in a worker thread.

This makes pino.destination a wrong choice because it runs in the main thread. Therefore to get the best performance out of Pino we must use v7+ transports.

In our case we want to log to stdout, therefore we create a pino/file transport:

const transport = pino.transport({
  target: "pino/file",
});

const logger = pino(transport);

Having a section in the documentation about running Pino in production would be great. Unfortunately, there are too many options at the moment, which can confuse new users of Pino (or even existing users like myself).

Contributor guide