我对温斯顿很困惑.我使用以下打字稿代码登录我的* .ts文件中的控制台: import { Logger, LoggerInstance } from "winston";const logger:LoggerInstance = new Logger();logger.info('Now my debug messages are written to t
import { Logger, LoggerInstance } from "winston";
const logger:LoggerInstance = new Logger();
logger.info('Now my debug messages are written to the console!');
控制台仍然是空的.没有编译错误或其他问题.
同时以下工作正常:
const wnstn = require("winston");
wnstn.info('Finally my messages are written to the console!');
有没有人知道为什么会这样?我是否必须以不同方式配置Logger?我如何使用第二个例子中的默认值?
当您实例化一个新的Logger实例时,您需要为它提供一个传输列表,以便它知道在哪里发送日志:var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: 'somefile.log' })
]
});
