DEV Community

Discussion on: HTTP request logging in Node.JS

Collapse
 
davicente profile image
David Vicente Fuentes

I was struggling with this same problem time ago. The problem I found with your approach is that you need to pass the request object all over your code, which gets it dirty.
Finally, I made a wrap of Winston logger library, and used another libraries for sharing variables withoug passing them through function calls, and it works pretty well. The library generate and manage a unique request Id and print it with every log, so you can abstract from this problem.
Hope it helps:
github.com/davicente/express-logge...