Node.js winston日志记录器;如何在将日志插入日志文件时从新行开始?

3

我正在制作一个Node.js应用程序,大部分的日志记录都使用Winston。 但是我发现所有的记录都在同一行中,我想为每个日志记录更改行,有什么方法可以做到这一点吗? 我的代码:

var winston = require("winston"); var logger = new(winston.Logger)({
transports: [
new(winston.transports.Console)(),
new(winston.transports.File)({filename: './log/logFile.log', handleExceptions: true, json:true})
]

就像这样:

})

{"level":"info","message":"test","timestamp":"2012-12-05T07:12:23.774Z"}

{"level":"info","message":"test","timestamp":"2012-12-05T07:15:16.780Z"}
1个回答

5
这不是winston的问题。Winston使用Unix风格的换行符(即只有一个字符xOA)。
你只需要停止使用Windows记事本,开始使用其他文本编辑器(如Notepad ++Sublime)或类似Enide Studio的IDE。
顺便说一句,新版本的winston有时间格式选项。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接