Hi, i've this code:
var winston = require('winston');
// Remove logging on console
winston.remove(winston.transports.Console);// Configure the logger category
winston.loggers.add('accesslog', {
file: {
filename: './logs/access.log'
}
});winston.loggers.add('applog', {
file: {
filename: './logs/app.log'
}
});
It seems that winston doesn't remove console logging.
Have someone this problem too?
Thanks for your time.
Best regards.
Yes, did you resolve it?
It looks like it always pushing default transports in container.js:44
if (options.transports.length === 0 && (!options || !options['console'])) {
options.transports.push(this.default.transports[0]);
}
which is defined as container.js:21
this.default = {
transports: [
new winston.transports.Console({
level: 'silly',
colorize: false
})
]
}
changing this into
this.default = options.default || {
transports: [
new winston.transports.Console({
level: 'silly',
colorize: false
})
]
}
and then specifiying when you define your container / category would resolve this
default: []
I also had this problem, did following workaround.
winston.loggers.get('<your-logger-name>').remove(winston.transports.Console)
Dont know, why it attaches the console trasnport, even if only file transport is provided.Or am i missing something here
@ Winston Maintainers, please have look into this !!
Regards,
/ajduke
Having the same problem and have posted on SO. If anyone comes up with an answer please answer it here: http://stackoverflow.com/questions/32649857/how-can-i-stop-loggly-from-printing-to-stdout-or-stderr-and-just-sending-the-l
Also, ajduke, if you come back and see this what do you mean by "your-logger-name". I'm never providing a name - just going by the instructions here: https://www.loggly.com/docs/nodejs-logs/
This, this, lost 3 hours!!!!
This is fixed in winston@3 which will be getting released next week.
@ajduke Thanks! That helped
[email protected] the issue is still there.
[email protected] the issue is still there - even with this atrocity, whenever a file log is added, it outputs to console too:
var name = 'my-logger';
var logger = new winston.Logger({
label: name,
level: 'debug',
handleExceptions: false,
transports: [],
});
logger.exitOnError = false;
// Browser equivalence
logger.notice = logger.info;
//
try { logger.remove(winston.transports.Console); } catch (e) {}
try { logger.remove(winston.transports.File); } catch (e) {}
FWIW, workaround that works for me:
winston.loggers.add("mylogger", {
transports: [
new (winston.transports.File)({
fileName: "/path/to/my.log"
})
]
});
Most helpful comment
[email protected] the issue is still there.