Winston: How to colorize just Console transport?

Created on 17 Apr 2018  路  2Comments  路  Source: winstonjs/winston

How to add colors only in console and not in file transport?

const logger = createLogger({
  format: combine(
    timestamp(),
    prettyPrint(),
    myFormat
  ),
  transports: [
    new transports.Console(),
    new DailyRotateFile({
      filename: path.resolve(logsDir, 'application-%DATE%.log'),
      datePattern: 'YYYY-MM-DD',
      zippedArchive: true,
      maxSize: '20m'
    })
  ]
})

It seems the option colorize: true doesn't works:

new transports.Console({colorize: true})

Most helpful comment

Yes, that option was removed in [email protected] in favor of the formats.colorize(). I added an example showing what you need to do in 391aa2b

All 2 comments

Yes, that option was removed in [email protected] in favor of the formats.colorize(). I added an example showing what you need to do in 391aa2b

Thanks @indexzero
It works now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xungwoo picture xungwoo  路  3Comments

amiram picture amiram  路  4Comments

pocesar picture pocesar  路  3Comments

anks333 picture anks333  路  3Comments

JaehyunLee-B2LiNK picture JaehyunLee-B2LiNK  路  3Comments