'debug' level is getting directed to stderr instead of stdout
See original GitHub issueSetup
- winston version 2.2.0
- node version 4.4.7
Repro Steps
-
Save the following into a file named app.js:
'use strict'; const winston = require('winston'); const log = new winston.Logger({ levels: { error: 3, warning: 4, notice: 5, info: 6, debug: 7, }, transports: [ new (winston.transports.Console)({ level: 'debug', }), ], }); log.error('test error'); log.warning('test warning'); log.notice('test notice'); log.info('test info'); log.debug('test debug');
-
Run the app with command:
node app.js > app.log 2>err.log
-
View the contents of err.log and notice that the
log.error
andlog.debug
output both ended up in there (former expected, latter not expected). View the contents of app.log and notice that thelog.warning
,log.notice
, andlog.info
output all ended up in there (as expected). -
Edit app.js to find/replace all 4 instances of ‘debug’ with any other word - e.g. ‘debugz’.
-
Run the app (again) with (the same) command:
node app.js > app.log 2>err.log
-
Notice how all the stuff ends up in the same file, except that the
log.debugz
output is now in app.log and not in err.log.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to redirect stdout and stderr to logger in Python
It works both with python2 and 3, in case you log to a file (e.g. logging.basicConfig(filename='example.log', level=logging.DEBUG). But if you want e.g. logging...
Read more >debug output is written to stderr instead of stdout #5187 - GitHub
Redirecting the stderr to stdout is a possible solution, but this will of course also redirect real errors.
Read more >Redirect stdout and stderr to a logger in Python
I'm writing a daemon and needed a method of redirecting anything that gets sent to the standard out and standard error file descriptors...
Read more >Linux : how to redirect stdout & stderr to logger?
The first part ( echo info; >&2 echo critical ) simulate a program that output both on stdout and stderr.
Read more >BASH Shell Redirect stderr To stdout ( redirect stderr to a File )
Explains how to redirect stderr to stdout to a file or vice versa in ... apt-get -y install lxd wireguard vnstat expect mariadb-server...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found the answer here: https://github.com/winstonjs/winston/blob/master/docs/transports.md
… i.e. setting the levels to log to stderr instead of stdout via
stderrLevels
transport option.FWIW, I didn’t find it very intuitive that this option would default to
['error', 'debug']
, but that may be based on my own ignorance of how that default would make sense.I’ll let someone on the project close this issue after reading this feedback, but I need no additional help.
Debug logging does not indicate an error in my eyes. Good that it can be changed via
stderrLevels
, but shouldn’t the default be['error']
in stead of['error', 'debug']
?