Hello,
From the documentation I see it's possible to reconfigure a transport's level at runtime, but the sample uses a custom logger. Is it possible to do the same with the default logger?
Something like:
var winston=require('winston');
winston.debug("Will not be logged!");
winston.transports.console.level = 'debug'; <--- There is no "console" in transports!
winston.debug("Will be logged in console!");
I've tried to change "console" to "Console" but it does not work...
Thanks!
Answering to myself, just in case anybody else asks... I've accessed the default logger through the "Winston.default" property. From there, I can access the transports and do exactly as explained above.
I assume (hope) this is the correct way of proceeding.
This is a sample:
var winston=require('winston');
// Add another transport as an example
winston.add(winston.transports.File, { filename: "somelog.log" });
winston.debug('By default it will not log debugs on console');
// Turn on debugs on default logger console transport
winston.default.transports.console.level='debug';
winston.debug('Now it will log debugs only on console');
// Turn on debugs on default logger file transport
winston.default.transports.file.level='debug';
winston.debug('Now it will log debugs both on console and on file');
Most helpful comment
Answering to myself, just in case anybody else asks... I've accessed the default logger through the "Winston.default" property. From there, I can access the transports and do exactly as explained above.
I assume (hope) this is the correct way of proceeding.
This is a sample: