2.4.0 eats Error objects when logging
See original GitHub issueAfter upgrading from 2.3.0 to 2.4.0, winston stops logging errors when using:
logger.error("Message", new Error("hello"));
I am using this piece of code for formatter
function configuredFormatter(colors) {
/**
* @param {Object} options
* @return {string}
*/
return function formatter(options) {
let {
meta,
level,
label,
message,
timestamp
} = options;
let {
from,
stack, trace,
message: objectMessage
} = meta;
delete meta.from;
delete meta.message;
delete meta.stack;
delete meta.trace;
let formattedMessage = new Message()
.setColorizer(new Colorizer(colors))
.setTime(timestamp)
.setLabel(label)
.setLevel(level)
.setFrom(from)
.setMessage(message || objectMessage)
.toString();
formattedMessage += utils.getStackTrace(stack || trace);
formattedMessage += utils.metaToYAML(meta);
return formattedMessage;
};
}
on 2.4.0 there is no stack/trace etc. there is no sign of the error object in the arguments. the result is that the error is not printed to logs correctly.
downgrading to 2.3.0 fixes the problem.
upgrading to 3.0.0-rc1 + using winston.createLogger makes the app loop forever displaying the first log message which is really weird 😐
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Spring Loggin not showing in the console - Stack Overflow
i am struggling with Spring Boot Loggin. I am not able to print log.info or log.error on ...
Read more >Magento 2.4.3 : Type Error occurred when creating object ...
First : Try to rm -rf generated/ then bin/magento setup:di:compile to be sure your generated code is the good one. If the error...
Read more >Bug listing with status RESOLVED with resolution FIXED as at ...
Bug :2 - "How do I attach an ebuild. ... Bug:468 - "Zope 2.4.0/2.5.0 both give error about Makefile.pre.in not having boot target"...
Read more >HAProxy 2.4 Changelog
REGTESTS: ssl/log: test the log-forward with SSL - DOC: fix TOC in starter guide for subsection 3.3.8. Statistics - BUG/MEDIUM: captures: free() an...
Read more >console.log() - Web APIs - MDN Web Docs
Please be warned that if you log objects in the latest versions of Chrome and Firefox what you get logged on the console...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are discussions on the exact same problem here…nothing was fixed since, sadly. https://github.com/winstonjs/winston/pull/977 https://github.com/winstonjs/winston/pull/1042 #1007
It seems there is the same problem in v3.3.3. It eats/swallows error.message if error is provided with a introduction string, like this:
logger.error('ops', new Error('this will not be visible'));
While this will work:logger.error(new Error('this will be visible'));