pino is a very low overhead Node.js logger.
Questions tagged [pinojs]
62 questions
10
votes
2 answers
Logging to STDOUT and a file with node/pino
I am sharing this as I struggled to get a pino logger to write to both STDOUT and a log file:
const dest = new stream.PassThrough();
dest.pipe(process.stdout);
dest.pipe(fs.createWriteStream('/logs/file.log', { flags: 'a' }));
const logger = pino({…

Olivier D.
- 164
- 1
- 11
7
votes
1 answer
How to console log in terminal and write in file at the same time with Pino and Express.js
I have this simple function that I created to log whatever happens in my code:
const pino = require('pino')
module.exports = pino({
transport: {
target: "pino-pretty",
options: {
translateTime: "SYS:dd-mm-yyyy HH:MM:ss",
…

dokichan
- 857
- 2
- 11
- 44
6
votes
0 answers
Getting uncaughtException: Error: Cannot find module '...\.next\server\app\home\lib\worker.js' when trying to use pino.transport in Next.js
I have created a Next.js project with typescript using create-next-app. For logging of this particular project I have decided to use Pino logging library as it is recommended by Next.js itself.
When I am using Pino without its transport…

user22177053
- 61
- 1
6
votes
1 answer
pino-datadog-transport with Next.js on Vercel
I'm trying to migrate a Next.js project running on Vercel from
"pino-datadog": "2.0.2",
"pino-multi-stream": "6.0.0",
to
"pino": "8.4.2",
"pino-datadog-transport": "1.2.2",
and I copy the setup from the pino-datadog-transport's…

simonauner
- 1,021
- 1
- 8
- 10
6
votes
0 answers
How I can serialize an error object with pino?
I'm just starting out using pino and I am trying to serialize an error object but it doesn't work. This is the code I am using:
const log = pino({
name: "pino",
timestamp: pino.stdTimeFunctions.isoTime,
level: "trace",
serializers:…

khadija zekraoui
- 101
- 7
6
votes
1 answer
pino-pretty, how to add file name to log line
i need to add file name to pino-pretty line output,
now i'm using:
const pino = require('pino');
const logger = pino({
prettyPrint: {
colorize: true,
translateTime: 'yyyy-mm-dd HH:MM:ss',
ignore: 'pid,hostname'
…

Vadim
- 402
- 6
- 15
5
votes
0 answers
Node.js / Pino.js: How to rotate logs in a separate thread
I am trying to use pino for logging in to my node app Server and I do have some large logs coming, so rotating the files every day would be more practical.
So I used pino.multistream() and require('file-stream-rotator')
My code works, but for…

Noweh
- 583
- 5
- 16
5
votes
2 answers
using pino multistream with synchronous logging
from what I understand, Pino (v 7.5.1) by default does sync logging. From the docs
In Pino's standard mode of operation log messages are directly written to the output stream as the messages are generated with a blocking operation.
I am using…

punkish
- 13,598
- 26
- 66
- 101
5
votes
4 answers
how can i rotate log files in pino.js logger
I am trying to use pino for logging in to my node app Server and I do have some large logs coming, so rotating the files every day would be more useful for reading the logs afterwards.
I can do this using morgan but with pino I can't find a way to…

Kaki Master Of Time
- 1,428
- 1
- 21
- 39
4
votes
2 answers
Setting Pino level gives me 'log_1.default.level is not a function'
I have set up a log utility module using Pino in a KeystoneJS/NodeJS project. It works fine, but I want to limit the log level when it goes into production.
The utility file, util/log.js is set up
import pino from 'pino';
const logger = pino({
…

Cerulean
- 5,543
- 9
- 59
- 111
3
votes
1 answer
How to add tracking id for each request in fastify?
Im using fastify as backend of my app. I also using pino logger.
const fastify = require('fastify')({
logger: true
})
I need that every time Im writing fastify.log.info("something") I need to see the log (in my terminal) with some trackingId. Like…

Arseniy Klibaner
- 37
- 4
3
votes
0 answers
How to redact query string parameter from fastify pino logs
I'm using Fastify and would like to redact querystring parameters in the logged request, eg:
"url": "/auth?token=XXXXXXX"
I've looked through the pino documentation on redaction, and can't find how to replace just part of the url value and not the…

Ben Davis
- 13,112
- 10
- 50
- 65
3
votes
1 answer
How to tell TypeORM to use different logger (pino in this case)?
I am using NestJS, TypeORM, pino and nestjs-pino.
I need pino for my logs to be in JSON format, so that Google Cloud Logging can parse the logs.
However, TypeORM logs are not in JSON format. They still somehow use their own logger.
Is it possible to…

Harold L. Brown
- 8,423
- 11
- 57
- 109
3
votes
1 answer
pino loses log entries on process.exit()
When my program shuts down via process.exit() (maybe also by some signal), pino loses some log entries because it is not properly flushing them.
Triggering a manual flush does not help.
I am using pino 6.2.0.
How can I prevent log entries from…

Arc
- 11,143
- 4
- 52
- 75
2
votes
1 answer
access request ID outside middleware in nestjs pino
Actually, I'm saving activity logs in my database and I also want to save the associated reqId so I can track down problems later if any arise. I need to access the log request ID outside of the logger.log function. I also mentioned the scenario…

Zain Khan
- 1,644
- 5
- 31
- 67