I'm trying to use winston container but the message formatting doesnt seem to happen.
Using the 'createLogger' approach i can see it works
const consoleTransport = new winston.transports.Console();
// logger object with above defined options
const logger = winston.createLogger({
transports: [consoleTransport],
format: winston.format.combine(
winston.format.splat(),
winston.format.simple(),
)
});
logger.stream = {
write(message) {
logger.info(message);
},
};
logger.info("This is my placeholder %s", "test");
I can see the output is correct
info: This is my placeholder test
But using a container
const consoleTransport = new winston.transports.Console();
// Create a container and set the format at the container level
const container = new winston.Container({
transports: [consoleTransport],
format: winston.format.combine(
winston.format.timestamp(),
winston.format.splat()
),
});
// Create a logger within the container
container.add('test1', {
level: 'info',
});
const log1 = container.get('test1');
log1.info("This is my placeholder %s", "test");
module.exports = container;
The formatting doesnt work... what am i doing wrong?
{"level":"info","message":"This is my placeholder %s"}