I'm just interested in the best approach to the following...
I have an app that is split into a few modules for maintenance reasons and separation of concerns. I want to be able to create a log file when my app starts and then using the different modules I have written write to the same log file without it becoming messy and having unneeded code in my exported modules.
Thanks in advance.
We already know that logging is affecting performance, especially when we use console. log because its a syncronous process. In nodejs, we have to use asyncronous process to get the best performance.
Each module in Node. js has its own context, so it cannot interfere with other modules or pollute global scope. Also, each module can be placed in a separate . js file under a separate folder.
Use Winston for logging, it can log in a file, db, anything and it has a good documentation. You can use Winston to log messages across all of your modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With