Winston logger
Course: Monitoring, Logging and Newrelic - chapter 9
Transports
Section titled “Transports”Winston lets you stash logs in various places (files, console, postgres tables etc)
const logger = winston.createLogger({ transports: [ new winston.transports.Console(), new winston.transports.File({ filename: 'combined.log' }) ]});💡 Good list of transports - https://github.com/winstonjs/winston/blob/master/docs/transports.md#postgresql-transport
Formats
Section titled “Formats”import winston from 'winston';const logger = winston.createLogger({ level: 'info', format: winston.format.combine( winston.format.timestamp(), winston.format.prettyPrint() ), transports: [ new winston.transports.File({ filename: 'error.log', level: 'error' }), new winston.transports.File({ filename: 'combined.log' }), ]})
logger.error('Hello, world!');logger.info('Hello, world!');