It looks like 3.0 is logging {} for Error objects
See original GitHub issueHi All I am having some hassle with winston 3.0 logging empty error objects when it is using a json format.
module.exports = winston.createLogger({
format: format.combine(
format.label({ label: 'my label'}),
format.timestamp(),
format.prettyPrint()
),
transports: [
new (winston.transports.Console)({
level: error
})
]
});
logs the expected
{error: [stack trace here] }
while
module.exports = winston.createLogger({
format: format.combine(
format.label({ label: 'my label'}),
format.timestamp(),
format.json()
),
transports: [
new (winston.transports.Console)({
level: error
})
]
});
logs the erroneous
{error: {} }
when it is passed
logger.log({
error: new Error('my error message')
});
Manually creating a format with
winston.format.printf
also returned the erroneous result.
Does anybody know of a workaround for this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Logging errors in Slim 3 - Rob Allen's DevNotes
In this post, I'm going to look at error handling. ... App\Handlers\Error object and then retrieve the Logger from the container as we...
Read more >Log shows Error object: {"isTrusted":true} instead of actual ...
I have an event handler that looks like this ...
Read more >LoggerExtensions.LogError Method - Microsoft Learn
Formats and writes an error log message. LogError(ILogger, EventId, Exception, String, Object[]). Formats and writes an error log message.
Read more >logging — Logging facility for Python — Python 3.11.1 ...
Logs a message with level ERROR on this logger. The arguments are interpreted as for debug() . Exception info is added to the...
Read more >Designing Error Messages and a Logging Strategy in Node.js
So let's see what a proper logging strategy looks like and how we can structure our error messages to be helpful.
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
More concise version:
But this is what I actually do to have pretty logs locally and JSON errors in production:
which gives me this in production
and this in development
I’m running into this as well. Shouldn’t winston handle this out of the box? @indexzero what do you think about this?