emisqwe emisqwe - 3 months ago 27
Node.js Question

Winston logger not being printed on new line

This is my winston logger -

var winston = require('winston')

var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
// log which takes care of all the MAS scoring - node clusters and servers
filename: './test.log',
level: 'info',
json: true,
eol: 'rn'
})
]
})


And when I run the actual logger:

logger.info('hi', 'it meeeeee')
logger.info('hi', 'it youuuuuu')


It prints out like this in the test.log file -

{"level":"info","message":"hi it meeeeee","timestamp":"2016-08-18T08:42:01.768Z"}rn{"level":"info","message":"hi it youuuuuu","timestamp":"2016-08-18T08:42:01.770Z"}rn


And I want it to be like this:

{"level":"info","message":"hi it meeeeee","timestamp":"2016-08-18T08:42:01.768Z"}
{"level":"info","message":"hi it youuuuuu","timestamp":"2016-08-18T08:42:01.770Z"}


How is this possible? I have read this question Node.js winston logger; How to start from a newline when insert log into log file? - however it does not solve the issue in my case.

I.e. if I open in Notepad ++, command line or Sublime text I still get the same issue.

Answer

Try this eol: \r\n

Look official documentation

Comments