-
I keep seeing sources suggesting that the global logger should be avoided. For example, this comment and this FAQ entry. However, I can't seem to find an explanation as to why it should be avoided. One thing that comes to mind is that you lose some control of child loggers and their context. Why else is it discouraged? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @jalaziz. There are no known bugs/limitations with the global logger, if that's your concern. Your application will not misbehave if you use it. Zap just believes that it's better application design to use an explicitly passed logger over the implicit global. |
Beta Was this translation helpful? Give feedback.
Hey @jalaziz.
Zap leans towards the philosophy of plumbing your dependencies explicitly where possible.
A global logger is provided, but we encourage that components that want to do any logging accept a logger as a constructor parameter and record it for later use.
There are no known bugs/limitations with the global logger, if that's your concern. Your application will not misbehave if you use it. Zap just believes that it's better application design to use an explicitly passed logger over the implicit global.