Node.js Winston记录器;将日志插入日志文件时,如何从换行符开始?

Node.js Winston记录器;将日志插入日志文件时,如何从换行符开始?

问题描述:

我正在制作一个Node.js应用程序,并且我将Winston用于大多数日志记录目的. 但是我在一行中找到了日志文件中的所有记录,我想为每个日志记录更改行,有什么办法可以做到这一点? 我的代码;

I'm making a Node.js app and I am using Winston for most of my logging purposes. But I find all records in log file in one line, I want to change line for every log record, any way can do this? My code;

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"}

这不是Winston问题. Winston使用Unix样式作为换行符(即仅一个字符xOA).

It is not winston issue. Winston uses Unix style for new line (i.e. only one character xOA).

您只需要停止使用Windows记事本,然后开始使用其他文本编辑器(例如 Notepad ++ Sublime )或类似

You just need stop using Windows Notepad, and start using other text editor (like Notepad++, Sublime) or IDE like Enide Studio.

BTW较新的winston具有时间格式选项.

BTW newer winston has options for time format.