What exactly is the use of defining level in the top-most scope?

Viewed 28

I was just going through the Winston logger usage guide and came across the following usage:

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  defaultMeta: { service: 'user-service' },
  transports: [
    //
    // - Write all logs with importance level of `error` or less to `error.log`
    // - Write all logs with importance level of `info` or less to `combined.log`
    //
    new winston.transports.File({ filename: 'error.log', level: 'error' }),
    new winston.transports.File({ filename: 'combined.log' }),
  ],
});

What is the use of defining level: 'info', if you're going to have level: 'error'? Or is it the case that the latter is overriding level: 'info',, because according to the docs the outer level does the following:

Log only if info.level is less than or equal to this level

So what exactly is the use of defining level in the top-most scope?

0 Answers
Related