How can I redirect everything what is displayed in console to a file?
I mean for example, i call some function, this function display something on console (no metter if it is console.log
or process.stdout.write
)?
Thanks for help!
How can I redirect everything what is displayed in console to a file?
I mean for example, i call some function, this function display something on console (no metter if it is console.log
or process.stdout.write
)?
Thanks for help!
While not strictly a Node.js answer, you could achieve this at the shell level. For example if you are using bash, you could redirect both standard output and error stream to a file using the following
#!/bin/bash
node app.js &> output.log
Check out also tee
command for simultaneous output to both file and screen.