Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

459
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda