Winston Node creates log file but does not save: Attempt to write logs with no Transports

Asked

Viewed 266 times

2

I have a problem in Winston, follow my settings:

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transport: [
    new winston.transports.File({ filename: './../error.log', level: 'error', json: true }),
    new winston.transports.File({ filename: './../info.log', json: true }),
    new winston.transports.Console()
  ]
});

Here’s the piece of code I request to log:

.catch(err => logger.error({
   message: 'Erro ao cadastrar usuário',
   data: err
}));

Here is the alert that appears in the attempt to generate the log:

NOTE: I am only sending the beginning of the message that appears because it is a bit big because of json

[winston] Attempt to write logs with no transports {"message":"Erro ao cadastrar usuário","data":{"name":

This is my problem, in trying to generate the log it returns me this.

1 answer

2


Speak Pedro, missing one’s' in logger configuration.

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transports: [ //transports ao invés de transport
    new winston.transports.File({ filename: './../error.log', level: 'error', json: true }),
    new winston.transports.File({ filename: './../info.log', json: true }),
    new winston.transports.Console()
  ]
});

Correct there that will work correctly.

  • I will test here, if it works mark as right hheheehe. If it works was a fucking wobble ahuaha

Browser other questions tagged

You are not signed in. Login or sign up in order to post.