Winston: Debug log written to stderr

Created on 22 Feb 2015  路  5Comments  路  Source: winstonjs/winston

Test case:

var logger = require('winston');
logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {'timestamp': true, 'showLevel': false, 'level': 'debug'});

logger.info('info');
logger.debug('debug');
logger.error('error');

Output:

$ node test-winston.js 2>/dev/stdout 1>/dev/null
2015-02-22T11:37:59.072Z - debug: debug
2015-02-22T11:37:59.203Z - error: error

$ node test-winston.js 1>/dev/stdout 2>/dev/null 
2015-02-22T11:40:56.820Z - info: info

Expected result (disregarding the timestamp copy/paste) would be:

$ node test-winston.js 2>/dev/stdout 1>/dev/null
2015-02-22T11:37:59.203Z - error: error

$ node test-winston.js 1>/dev/stdout 2>/dev/null 
2015-02-22T11:40:56.820Z - info: info
2015-02-22T11:37:59.072Z - debug: debug

Winston version: 0.9.0,
Node.js version: 0.10.18.

Most helpful comment

why is it a feature to spam my error logs with debug logs?

All 5 comments

Interesting. Nothing in the code looks wrong. Could you add a javascript-based test to our suite?

It's a feature, not a bug :+1:
Although an undocumented feature :-1:
The pull request contains the README update.

How can this be avoided ? It confuses some test runners such as cucumber-js

why is it a feature to spam my error logs with debug logs?

This behaviour is also very confusing on Cloud Foundry based platforms (e.g. IBM Bluemix). The standard debug log messages are all classified as errors :-(

Took me a while to find https://github.com/winstonjs/winston/issues/927 ... which explains that it can be configured via the stderrLevels parameter (which I've now done). Still a bit unexpected, that the default behavior is for INFO level messages to route to stdout

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Buzut picture Buzut  路  3Comments

amiram picture amiram  路  4Comments

mohanen picture mohanen  路  4Comments

Tonacatecuhtli picture Tonacatecuhtli  路  4Comments

JaehyunLee-B2LiNK picture JaehyunLee-B2LiNK  路  3Comments