Thursday, 13 April 2017

Winston writes the object but not the meta data (msg, level, timestamp)

winston version: 2.3.1
mongoose version: 4.2.3

I am logging errors thrown by mongoose. When I have a duplicate key error from mongoose, and I try to log it, winston only writes its error object. It does not write the error message and other meta data.

This is what gets written in the log file:

{"code":11000,"index":0,"errmsg":"E11000 duplicate key error collection: my-database.my-collection index: name_1 dup key: { : \"eiPr+HJDqO1XPM1GGCT/hQ==\" }","op":{"_id":"58ef68ba9a9556e116b629ee","isOn":true,"desc":"","name":"eiPr+HJDqO1XPM1GGCT/hQ==","__v":0}}

This is creating a lot of problems. I reading the logs and showing the error notifications on dashboard with time. But as there's no timestamp, its creating too many problems.

NOTE: This is happening with mongoose error object. Normal object is working.



via Dushyant Bangal

No comments:

Post a Comment