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

112
Views
Winston logger error logger.default.warn is not a function

I added Winston logger to my JS application and all the logs work but not the warning. I have no idea why.

The error every time I try to use .warn(warning) as

TypeError: _logger.default.warn is not a function

My logger was done in this helper utility

import { config, createLogger, format, transports } from 'winston';

const { printf, combine, timestamp, colorize } = format;

// don't show console logs in test mode
const transport =
  process.env.NODE_ENV !== 'test' ? [new transports.Console()] : [];

export default createLogger({
  levels: config.syslog.levels,
  level: 'info',
  format: combine(
    timestamp(),
    printf((info) => `[${info.timestamp}][${info.level}]: ${info.message}`),
    colorize({ all: true })
  ),
  transports: [
    ...transport,
    new transports.File({ filename: 'logs/error.log', level: 'error' }),
    new transports.File({ filename: 'logs/application.log' }),
  ],
});

and I used just under an if statement

if ( validation === 'false' ) {
    log.warn('Twilio validation is not active!'); // Here the error occur
    return next();
  }

I tried to google online but as per documentation should work so I don't know what's wrong as it is the only log not working.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

createLogger() creates the log level methods based on the levels object in the options. In config.syslog.levels the level is called warning not warn.

So the method to call should be: log.warning('Twilio validation is not active!');

There is an open issue requesting to implement warn() as a convenient method for syslog warning level.

about 4 years ago · Juan Pablo Isaza Report
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!