我试着用Winston
换logger
.我在一个项目中使用了他们的,当我将代码从他们的复制粘贴到当前现有的项目中时,它工作得很好,而我面临的问题是打字错误:温斯顿.记录器不是构造函数
让logger=new(winston.logger)({
打字错误:温斯顿.记录器不是构造函数
请指导我,为什么会出现这种错误,以及我应该如何解决这个问题.
"摩根":"^1.9.0","温斯顿":"^3.0.0"
以下是我在logger.js
文件中的代码.
var appRoot = require('app-root-path');
var winston = require('winston');
var options = {
file: {
level: 'info',
name: 'file.info',
filename: `${appRoot}/logs/app.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 100,
colorize: true,
},
errorFile: {
level: 'error',
name: 'file.error',
filename: `${appRoot}/logs/error.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 100,
colorize: true,
},
console: {
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
},
};
// your centralized logger object
let logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(options.console),
new (winston.transports.File)(options.errorFile),
new (winston.transports.File)(options.file)
],
exitOnError: false, // do not exit on handled exceptions
});