Skip to content

Why is the global logger discouraged? #1283

Answered by abhinav
jalaziz asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jalaziz
Comment options

Answer selected by jalaziz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants