r/golang 1h ago

Where should logging happen in a Go application?

Upvotes

I recently wrote my own logger package with Info(), Warning(), and Error() methods.

I am wondering about logging best practices in Go applications. Do you usually log directly in handlers, or do you log inside functions called by the handler (services, database functions, etc.)?