Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
pino logger and express attach custom property to all logs

First up, node is not my thing. Nevertheless I find myself trying to figure out how to combine pino/pino-http and express to deliver some formatted logs. This part I have achieved.

What I was attempting to figure out for a short while was how to pass express via app.use(logger) a logger object that has got some base properties injected into it.

I tried a bunch of stuff, including creating a child logger and passing that to pinoHTTP() but although that did not error, i'd end up getting very long log objects which seemed full of goop and undesirable content.

pseudo code

const express = require('express');
const pino = require('pino');
const log = pino({level: process.env.LOG_LEVEL || 'info'});
const childLogger = log.child({'exampleProp': 'example-value'});


const logger = require('pino-http')({
  logger: childLogger
});

const app = express();
const port = 3000;

app.use(logger);

app.get('/', (req, res) => {
  logger.info('Hello World');
  res.send('Hello World!');
});

app.listen(port, () => {
  console.log('Example app listening on port ${port}')
});

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!