Search code examples
node.jsloggingseparation-of-concerns

nodejs and logging through different modules


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.


Solution

  • 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.