📅  最后修改于: 2022-03-11 15:02:54.028000             🧑  作者: Mango
const winston = require('winston');
const loggers = {
mjson: winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [new winston.transports.File({ filename: 'app-info.log'})],
}),
simple: winston.createLogger({
level: 'error',
format: winston.format.simple(),
transports: [new winston.transports.File({ filename: 'app-error.log'}),],
})
};
loggers.mjson.info('Information message');
loggers.mjson.error('Error message');
loggers.mjson.debug('Some message');
loggers.simple.error('Error message');
loggers.simple.info('Information message');
loggers.simple.warn('Warning message');
loggers.simple.debug('Some message');