javascript - Winston createLogger 自定义函数
问题描述
在我的节点应用程序中,我使用 winston 进行错误记录。我想在一个地方创建一个函数并在 server.js 文件中使用它。这是我的文件
const exceptionLogger = () => {
createLogger({
exceptionHandlers: [
new transports.File({ filename: 'exceptions.log' }),
],
});
};
但是这个函数不能被称为exceptionLogger()。它使应用程序崩溃。这是什么原因?我怎样才能以正确的方式做到这一点?
解决方案
你可以试试这个:
export const exceptionLogger = () => {
winston.createLogger({
exceptionHandlers: [
new winston.transports.File({ filename: 'exceptions.log' }),
],
});
};
推荐阅读
- java - 保存checkedtextview状态的问题,它对多个项目行为不端
- java - org.eclipse.jdt.internal.compiler.codegen.CodeStream.newArray 的 java.lang.NullPointerException
- python - git webhook 失败 - 你知道为什么吗?
- c# - 处理 WCF 主机中不断变化的 baseAddress
- unity3d - 创建游戏对象时的“新”操作员日志警告,如何解决?
- r - 使用 rbindlist 时遇到错误:结果的第 25 列被确定为 integer64 但 maxType == 'Character' !=REALSXP
- javascript - 为什么在 JQuery 中追加在跨度中重复?我不想重复标签
- ibm-cloud-functions - 该操作未产生有效响应并意外退出
- python - Python 模拟异常 http.client 响应
- mysql - 如何为以前输入的数据运行插入触发器?