Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

460
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda