You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When logging an uncaught exception with winston, the message property is always undefined when using the console transport
What version of Winston presents the issue?
v3.8.1
What version of Node are you using?
v22.3.0
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
const{ createLogger, transports, format }=require('winston');constlogger=createLogger({transports: [newtransports.Console({format: format.printf((info)=>`[${info.timestamp}] ${info.level}: ${info.message}`)})],level: 'debug'});process.on('uncaughtException',(err)=>{logger.error(err);});thrownewError('this text is lost and not shown anywhere');
Additional information
This is my full logger file, which hopefully shows why I'm handling uncaughtExceptions this way
I am also facing this issue. Basically, no exception is being logged. Even when I have logger.error(new Error('Some error'), The error log does not show up.
I dug in and I saw this getAllInfo method. Extracted it used it with logger.log() like
functiongetAllInfo(err: Error){return{level: 'error',error: err,message: [`${err.message||'(no error message)'}`,(err&&err.stack)||' No stack trace',].join('\n'),stack: err&&err.stack,exception: true,// date: new Date().toString(),process: getProcessInfo(),os: getOsInfo(),trace: getTrace(err),};}constlogError=(err: Error)=>logger.log(getAllInfo(err))logError(newError('Some error'))// Nothing is logged
But then I commented out the exception: true line, and it worked - the error log showed with the stack trace.
🔎 Search Terms
uncaughtException,message undefined, message,undefined
The problem
When logging an uncaught exception with winston, the message property is always undefined when using the console transport
What version of Winston presents the issue?
v3.8.1
What version of Node are you using?
v22.3.0
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
Additional information
This is my full logger file, which hopefully shows why I'm handling uncaughtExceptions this way
Perhaps I'm just going about this the wrong way?
The text was updated successfully, but these errors were encountered: