3 ms·
Could you elaborate why logging is a mess in the Go ecosystem?
by Cwizard 4y ago
Could you elaborate why logging is a mess in the Go ecosystem?
- fredrikholm 4y agoWouldn't call it a mess, but there is less consensus amongst the community. Logging is one of the areas where there is no established standard. That said, Zap (by Uber) has proved itself and is a solid choice. We've used it in several projects at [company], handling very high loads.
- gabereiser 4y agoDidn't the Go team say that there's a logging interface and that's where they are going to leave it. If you want more robust logging, you can add it. log.New() is for that purpose. If you want a struct-log, you'll have to define one for your needs. Logging is very environment specific. What I log to the console locally is different from what I log to, say, AWS CloudWatch in production. I think the stance on logging by the core Go team is the right way to go about it. Just provide a basic logger, an interface, and let the projects determine how they want to route those logs and what kind of data should it include.
- qzio 4y agoCan you provide a link to this interface? The log package in stdlib doesn’t let you specify levels, just a Printf unless Iam mistaken, and it is not an interface I believe.
- gabereiser 4y agoAh, it's not an interface but a struct. My mistake. The syslog part of the log package allows you to specify the priority. https://pkg.go.dev/log/syslog@go1.19#Priority https://pkg.go.dev/log/syslog@go1.19#Priority