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

458
Views
Node isn't logging error messages to MongoDB as expected

I'm trying to create an error message/log using "winston-mongodb" while sending it to my database. In my MongoDB Compass it created a log folder as expected, but there's no data in it.

Here's my code:

index.js

require("winston-mongodb");

winston.add(new winston.transports.MongoDB({ db: "mongodb://localhost/vidly_node_js" }));

genres.js

router.get("/", async (req, res) => {
   throw new Error("Could not get the genres.");
   const genres = await Genre.find().sort("name");
   res.send(genres);
});

I'm supposed to be getting this:

enter image description here

But this is what I keep getting:

enter image description here

What am I missing???

Also "throw new Error("Could not get the genres.")" is making the code down below in my get function "unreachable". Maybe that's the reason? If so, what do I need todo to fix it? Because it’s giving me an error that says:

TypeError: common.clone is not a function

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Upagrade winston-mongodb package to version 4+ to work with latest winston

https://github.com/winstonjs/winston-mongodb/issues/108

Winston 3 and mongodb 3 support is now in the winston-mongodb 4.x branch.

winston-mongodb 3.0 is not compatible with latest winston

https://github.com/winstonjs/winston-mongodb/tree/v3.0.1

Current version supports only mongodb driver version 2.x. If you want to use winston-mongodb with mongodb version 1.4.x use winston-mongodb <1.x.

over 4 years ago · Santiago Trujillo 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!