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
stderr
will be redirected toapp.err
, while output sent tostdout
will go intoapp.out
. For example this script:would write
goes to stderr
toapp.err
, whilegoes to stdout
would appear inapp.out
. This default behavior can be however overridden with thestderrLevels
property using which one can specify which debug levels go tostderr
.Alternatively, using
console
, the behavior is documented here - by default,console.error
goes tostderr
(i.e.,app.err
in your setup) whileconsole.log
would output tostdout
(app.out
).