vitaly-t vitaly-t - 4 months ago 8
Node.js Question

Node.js full console redirect into a file

When we want a Node.js application to redirect every

console.log
and
console.info
into a file, we can use either
>fileName
or
1>fileName
, which hooks into
process.stdout
.

And when we want a Node.js application to redirect every
console.warn
and
console.error
into a file, we can use
2>fileName
, which hooks into
process.stderr
.

But how can we redirect the complete console output (for all console methods) into a single file?

I'm looking for something that works on both Windows and Linux.

Answer

The following syntax works: > filename 2>&1

Per this thread: How can I redirect and append both stdout and stderr to a file with Bash?

Comments