0

How can I change the output of the console in javascript to a file? I want to do this like in java. How can I do this? I want the logs to end up in a file instead of in the console. I need this for all of my dependencies.

Node.js console.log() in txt file does not help. My project is a dependency itself.

a1cd
  • 17,884
  • 4
  • 8
  • 28
  • Maybe by overriding console.log implementation with `console.log = writeToFile` or something? – Allan Juan Dec 12 '21 at 17:54
  • But the problem is he need to call/replace new overrided function everywhere. @AllanJuan – Alok Prakash Dec 12 '21 at 18:00
  • You really haven't explained why the other answer showing you how to do an override doesn't help. What did you try and what differed from expectations? I suspect you will have a very difficult time trying to only override some logging and not all of the app above your package as well – charlietfl Dec 12 '21 at 18:01

0 Answers0