Winston与HAPI日志logging不起作用

我有一个启用Winston日志的项目,该项目使用HAPI。 我有以下代码:

logger.js --------- var winston = require('winston'); winston.emitErrs = true; var logger = new winston.Logger({ transports: [ new winston.transports.Console({ level: 'debug', json: false, colorize: true }) ], exitOnError: false }); module.exports = logger; module.exports.stream = { write: function(message, encoding){ logger.info(message); } }; server.js --------- var Hapi = require('hapi'); var logger = require('./conf/logger.js'); var server = new Hapi.Server({ }); server.connection({ port: 3000 }); server.register([require('./modules/healthcheck.js'), require('vision')], (err) => { if (err) { console.error('Failed to load a plugin:', err); } }); server.start(function () { logger.info('Server started at ' + server.info.uri); }); healthcheck.js -------------- var logger = require('./conf/logger.js'); var healthchkPlugin = { register: function (server, options, next) { server.route({ method: 'GET', path: '/', handler: function (request, reply) { logger.info("health check api invoked"); reply("gateway up and running"); } }); next(); } } healthchkPlugin.register.attributes = { name: 'healthchkPlugin', version: '0.0.1' }; module.exports = healthchkPlugin; 

当我运行server.js并用GET请求命中终点时,控制台显示如下:

info:服务器从http:// <>:3000启动

但我期望它显示在GET处理程序中指定的信息语句。 我在这里做错了什么?