1

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!

Alexandr Lazarev
  • 12,554
  • 4
  • 38
  • 47
Filip
  • 105
  • 11

1 Answers1

0

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.

pspi
  • 11,189
  • 1
  • 20
  • 18