Reading How to log - the 12 factor application way it states to use this command :
node app.js 2> app.err 1> app.out
I understand the > operator sends the output of command to file.
So I could also use node app.js output.log.
For command node app.js 2> app.err 1> app.out what is the mechanism that determines if app.err or app.out is logged to. Is it by the logging level within in the app ? What extra config is required to send logging data to app.err & app.out ?
The expected behavior is that the output sent to
stderrwill be redirected toapp.err, while output sent tostdoutwill go intoapp.out. For example this script:would write
goes to stderrtoapp.err, whilegoes to stdoutwould appear inapp.out. This default behavior can be however overridden with thestderrLevelsproperty using which one can specify which debug levels go tostderr.Alternatively, using
console, the behavior is documented here - by default,console.errorgoes tostderr(i.e.,app.errin your setup) whileconsole.logwould output tostdout(app.out).