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

2

I have a problem with 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 is the piece of code where I request to generate 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'm just 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 gives me back this.

    
asked by anonymous 10.10.2017 / 22:32

1 answer

2

Speak Peter, there was an 's' in the 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.

    
11.10.2017 / 05:25