I cannot figure out how to disable JSON logging to a file. I want plain date: string logging.
// https://github.com/winstonjs/winston/blob/master/docs/transports.md#file-transport
logger = createLogger({
level,
json: false,
// format: [
// format.timestamp(),
// // format.printf(i => `${i.timestamp}: ${i.message}`),
// ],
transports: [new transports.File({ filename: 'query.log', json: false })],
});
This is the answer you are looking for:
const fs = require('fs');
const path = require('path');
const winston = require('winston');
const { createLogger, format, transports } = winston;
const logger = createLogger({
format: format.combine(
format.timestamp(),
format.printf(i => `${i.timestamp} | ${i.message}`)
),
transports: [
new transports.Stream({
stream: fs.createWriteStream(path.join(__dirname, 'example.log'))
})
]
})
logger.log({
level: 'info',
message: 'Check example.log 鈥撀爄t will have no colors!'
});
We should have this in the example
Most helpful comment
This is the answer you are looking for: