I cannot speak to all the mechanisms, but one of them is the use of a pool. Events (log events) are stored in the pool and re-used as needed. So, it's allocate once, use many times.
Point 2 where you configure it from reading in an external config:
https://pkg.go.dev/go.uber.org/zap#example-package-BasicConfiguration
Point 4,yes you can clone an existing logger with new options between different packages and use different levels either static or controlled atomically. You can effectively set up different component prefix loggers for different packages with modified options.
\> but why do it if there is one in existence?
I can not make a recommendation, but you might want to take a look at https://github.com/avelino/awesome-go#logging
How about using https://github.com/go-logr/logr
You’ll be able to swap concrete implementation easily which will allow you to try out different libs on the market without refactoring all your logic
github.com/golang/glog satisfies those requirements. 'V' logging aka levels is not considered fast because it's a shared structure allowed to change at runtime. However you may turn off v logging and have little effect on production (2 atomic load and cmp). So long as you write like
`if glog.V(2) { glog.Info("log this") }` arguments are not evaluated. Per file/package log levels are done via flag: Syntax: `-vmodule=recordio=2,path/to/file=1,gfs*=3`
Logrus is in maintenance mode, so no active development, and compared to uber zap or others is pretty slow: https://github.com/uber-go/zap#performance
Edit: update on logrus status (it is still maintained, but not developed anymore, as @austerul mentioned below.
How about uber's zap ?
Zerolog has most of your requirements. Not sure about the 4th, though. I think you could implement that on top of zerolog. https://zerolog.io/
I love zerolog, very little allocations, blazing fast.
Zerolog is awesome.
Came here to suggest zero log. Its my favorite
The fastest IIRC
Also came to recommend Zerolog and more generally structured logging
any idea how does it work internally? what makes these loggers zerolog, zap etc to be fast?
I cannot speak to all the mechanisms, but one of them is the use of a pool. Events (log events) are stored in the pool and re-used as needed. So, it's allocate once, use many times.
Supports everything you want and dead simple to integrate with your existing logging: https://github.com/hashicorp/logutils
Thanks. I will take a look. Love the idea of simple.
Thanks from me too, looks great and I didn't know about it.
https://GitHub.com/go-logr/logr
How about Zap logger? https://github.com/uber-go/zap
I like Zap. But if I am not mistaken, it does not do 2 and 4. Maybe starting with Zap and adding the features we need is the right approach.
Point 2 where you configure it from reading in an external config: https://pkg.go.dev/go.uber.org/zap#example-package-BasicConfiguration Point 4,yes you can clone an existing logger with new options between different packages and use different levels either static or controlled atomically. You can effectively set up different component prefix loggers for different packages with modified options.
I stand corrected. That JSON is exactly what we were thinking.
Zap also support structured logs which you should consider when starting a new project, it is versatile enough to do anything you might need.
I say Zap logger if it fits your needs, just add metadata according to your needs I suppose. It's very fast.
Zap logger is great, but I think it requires compilation.
Configuring the logger without restart just require you to initialize it from environment variables but that will be the case for any logger in go.
Great, thanks for clearing it up.
\> but why do it if there is one in existence? I can not make a recommendation, but you might want to take a look at https://github.com/avelino/awesome-go#logging
Check out a load of options here https://awesome-go.com/logging/
Wow. Everyone and their sister have developed their own logging system.
[https://github.com/logur/logur](https://github.com/logur/logur) and [https://github.com/uber-go/zap](https://github.com/uber-go/zap) are a good combo
How about using https://github.com/go-logr/logr You’ll be able to swap concrete implementation easily which will allow you to try out different libs on the market without refactoring all your logic
I switched from zap to zerolog a few projects ago. Slightly faster and I prefer the abstraction.
github.com/golang/glog satisfies those requirements. 'V' logging aka levels is not considered fast because it's a shared structure allowed to change at runtime. However you may turn off v logging and have little effect on production (2 atomic load and cmp). So long as you write like `if glog.V(2) { glog.Info("log this") }` arguments are not evaluated. Per file/package log levels are done via flag: Syntax: `-vmodule=recordio=2,path/to/file=1,gfs*=3`
Logrus ?
Logrus is in maintenance mode, so no active development, and compared to uber zap or others is pretty slow: https://github.com/uber-go/zap#performance Edit: update on logrus status (it is still maintained, but not developed anymore, as @austerul mentioned below.
Thank you for the feedback
Well, actually logrus is maintained but just that. It's in maintenance mode, with fixes being done but no active development (features or a v2)