Flatiron 的日志记录库 Winston 非常有用,但我不知道如何为记录器分配名称。我期待与其他日志库类似的输出,例如:
[<date>] [<log level>] <logger name> - <the message>
Winston可以这样配置吗?
谢谢。
创建日志传输时,您可以提供label
参数将添加到日志输出中的日志级别和日志消息之间。例如:
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
colorize: true,
prettyPrint: true,
timestamp: true,
label: 'CustomLabel'
})
]
});
这将产生以下输出:
2016-09-06T12:16:17.335Z - info: [CustomLabel] hello
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)