【问题标题】:Winston createLogger custom functionWinston createLogger 自定义函数
【发布时间】:2019-10-11 14:31:15
【问题描述】:

在我的节点应用程序中,我使用 winston 进行错误记录。我想在一个地方创建一个函数并在 server.js 文件中使用它。这是我的文件

const exceptionLogger = () => {
  createLogger({
    exceptionHandlers: [
      new transports.File({ filename: 'exceptions.log' }),
    ],
  });
};

但是这个函数不能被称为exceptionLogger()。 它使应用程序崩溃。这是什么原因?我怎样才能以正确的方式做到这一点?

【问题讨论】:

  • 函数导出了吗?
  • 是的,我导出了它。

标签: javascript node.js winston


【解决方案1】:

你可以试试这个:

export const exceptionLogger = () => {
  winston.createLogger({
    exceptionHandlers: [
      new winston.transports.File({ filename: 'exceptions.log' }),
    ],
  });
};

【讨论】:

  • 我导出了这个 Dino
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-17
  • 2018-11-21
  • 2014-12-03
  • 2018-10-29
  • 2015-02-14
  • 1970-01-01
  • 2021-11-06
相关资源
最近更新 更多