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

167
Views
Pino-tee logs twice on other logs

References: https://github.com/pinojs/pino-tee

I have two logs, info.log and error.log but the thing is, when I go to info.log, the log for error.log is there

So technically, What I have is :

error.log -> ERROR 1 (W/C correct)

info.log -> ERROR 1, INFO 1 (The error log is there)

What I want is that they go to seperate logs appropriately.

Heres the code from references link above:

const pinoms = require("pino-multi-stream");
const childProcess = require("child_process");
const stream = require("stream");

const cwd = process.cwd();
const { env } = process;

const logThrough = new stream.PassThrough();
const prettyStream = pinoms.prettyStream();
const streams = [{ stream: logThrough }, { stream: prettyStream }];
const log = pinoms(pinoms.multistream(streams));

const child = childProcess.spawn(
  process.execPath,
  [
    require.resolve("pino-tee"),
    "info",
    `${__dirname}/info`,
    "error",
    `${__dirname}/error`,
  ],
  { cwd, env }
);

logThrough.pipe(child.stdin);

module.exports = log;

Logging test on other file:

const logger = require("./Common/logger");
logger.info("INFO 1");
logger.error("ERROR 1");

Result:

info.log

{"level":30,"time":1651894649071,"pid":19380,"hostname":"","msg":"INFO 1"}
{"level":50,"time":1651894649074,"pid":19380,"hostname":"","msg":"ERROR 1"}

error.log

{"level":50,"time":1651894649074,"pid":19380,"hostname":"","msg":"ERROR 1"}
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!