Wednesday 7 June 2017

Request specific logging using Bunyan

I am using bunyan for logging service in my express-nodeJS application. I want to log per user/per request logging so that flow of request can be tracked down easily and will be easier to debug and keep a check on response time.
I am thinking to create a child logger on every request and attach user info to it and then attach that logger to request object.
My application is kind of mvc, so my model doesn't know about request object and most of the logging is being done in models only. Now with this approach I have to pass that child logger as parameter to every function call in function and then may be that needs to be passed in other adapters that model will call.
Is this the right way to do this ? As the codebase is really vast it will take time and every function needs to be updated. Can you suggest any better way to achieve same results will less changes in code ?



via krrish

No comments:

Post a Comment