首页 > 解决方案 > 节点 Winston 记录部分数据

问题描述

我刚刚winston从版本 2.4.4 更新到 3.1.2。以前它工作得很好,但现在它只记录消息的某些部分。

我有很多日志使生活成为现实:

logger.log("Operation 1", param1, param2, param3)
logger.error("Error 1", err, param1, param2)

在旧版本中记录的参数但在最新版本中只记录了forst字符串......有没有办法记录所有数据?

我附上我的配置

const fileTransport = new winston.transports.File({
        timestamp: () => moment().format('DD/MM/YYYY h:mm:ss:SSS'),
        filename: process.env.LOG_FILE,
        format: winston.format.json(),
        prettyPrint: true,
        maxsize: 5e+6,
    })

const consoleTransport = new winston.transports.Console({
    timestamp: () => moment().format('DD/MM/YYYY h:mm:ss:SSS'),
    colorize: true,
    format: winston.format.combine(
    winston.format.colorize(),
    winston.format.timestamp(),
    winston.format.prettyPrint(),
    winston.format( (info, opts) => {
      console.log(info)

      return `${info.timestamp} - ${info.level}: ${info.message} ${_.join(info.splat, ',')}`
    })
  ),
  })

谢谢!

标签: node.jswinston

解决方案


推荐阅读