What's the current industry standard for Golang logging libraries? #214
okdas
started this conversation in
Architecture
Replies: 1 comment
-
Our team had an internal discussion about this topic which I wanted to capture here We've decided to go with
Things we will keep in mind during future discussions and design decisions are:
This work is not currently tracked in any Github issues but will be in the future. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This research has originally been done in #181, but we still want to share this with the community in discussions for future reference.
There are so many different logging libraries!
What existing blockchain clients use
go-etherium: copied log15 into the codebase and made some modifications
Erigon: also fork of
log15
https://github.com/ledgerwatch/log/tree/master/v3AVAX: uber-go/zap
Algorand: logrus
CosmosSDK: zerolog
Comparison
rs/zerolog
anduber/zap
are libraries that avoid allocations and reflection, as a result they are incredibly fast. There is a traid off though in usability when going this route - because in order to avoid allocations one must specify a datatype for each field in logging event structure.uber/zap
has aSugaredLogger
mode when it still supportsprintf
-like syntax while still being pretty quick.logrus
seems to be the most popular solution, also a pioneer library that was most adopted (probably still is most popular?), with very human-friendly API. As it is imported in many existing software, maintainers avoid API-breaking changes that would be necessary to improve performace. Perf is still decent though!log15
is an old library that is no longer maintained. Hence it is forked by software that has been around for a while (such as geth). Its maintainer helped with development of github.com/go-kit/log, which is a part ofgokit
microservice framework.Final thoughts
I think we need to either use
rs/zerolog
oruber-go/zap
as they are not only most performant, but also being recommended bylogrus
maintainers. Though we don't necessarily need a very performant library for day-to-day operations, I can see a scenario when we want to dump all network messages client recieves into kafka/clickhouse or something similar for further analysis, and it'd be nice to have a smaller hit on performace.Please visit following pages to check out the API:
A few notes I would like to add:
BlockID
orBlockHash
as one of the arguments.Beta Was this translation helpful? Give feedback.
All reactions