You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how to dynamically change the log level in winston which will reflect a level change in multiple files.
I have two js files, in both files, I'm including logger, Let say If I change the level of the logger in index.js, but it will not reflect in readfile.js
Here is my code
winston_logger.js
var winston = require('winston');
var logger;
module.exports.init = function (logLevel) {
logger = new(winston.Logger)({
transports: [
new(winston.transports.Console)({
level: logLevel
})
],
exitOnError: false
});
}
module.exports.getLogger = function (config) {
if (!module.exports.logger) {
exports.init('info')
}
return logger;
}
module.exports.debugLevel = function(){
logger.transports.console.level = 'debug'
}
Index.js
var readFile = require('./readFile')
var winston = require('./winston_logger')
var log = winston.getLogger()
log.info("info message" );
/*Here Im changing the log level as debug*/
winston.debugLevel ();
setTimeout(function(){
readFile(function(){})
}, 5000)
readfile.js
var readFile = require('./readFile')
var winston = require('./winston_logger')
var log = winston.getLogger()
log.info("info message" );
/*Here Im changing the log level as debug*/
winston.debugLevel ();
setTimeout(function(){
readFile(function(){})
}, 5000)
Don't add these as a duplicate issue. these answers are not helped me
The text was updated successfully, but these errors were encountered:
how to dynamically change the log level in winston which will reflect a level change in multiple files.
I have two js files, in both files, I'm including logger, Let say If I change the level of the logger in index.js, but it will not reflect in readfile.js
Here is my code
winston_logger.js
Index.js
readfile.js
Don't add these as a duplicate issue. these answers are not helped me
The text was updated successfully, but these errors were encountered: