I have another question (last question). At the moment i am working on a Node.js project and in this I have many console.log() functions. This has worked okay so far but I also want everything that's written to the console to also be written in a log-file. Can someone please help me?
For example:
Console.log('The value of array position [5] is '+ array[5]);
In my real code its a bit more but this should give you an idea.
Thank you hopefully.
I would use a library instead of re-inventing the wheel. I looked for a
log4j
-type library on npm, and it came up with https://github.com/nomiddlename/log4js-nodeif you want to log to the console and to a file:
now your code can create a new logger with
and use the logger in your code