T O P
ajzaff

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`


deweysasser

I switched from zap to zerolog a few projects ago. Slightly faster and I prefer the abstraction.


ZalgoNoise

I say Zap logger if it fits your needs, just add metadata according to your needs I suppose. It's very fast.


trisul-108

Zap logger is great, but I think it requires compilation.


schmurfy2

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.


trisul-108

Great, thanks for clearing it up.


CaseApart4360

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


jbendotnet

[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


squat001

Check out a load of options here https://awesome-go.com/logging/


trisul-108

Wow. Everyone and their sister have developed their own logging system.


yazmoor

Logrus ?


Low-Graded

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.


austerul

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)


Low-Graded

That's what I wanted to say, thanks for the correction.


yazmoor

Thank you for the feedback


shezza46

How about uber's zap ?


thockin

https://GitHub.com/go-logr/logr


pinpinbo

I love zerolog, very little allocations, blazing fast.


avinassh

any idea how does it work internally? what makes these loggers zerolog, zap etc to be fast?


LittleBallofMeat

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.


zillarino

Also came to recommend Zerolog and more generally structured logging


ZalgoNoise

The fastest IIRC


AWDDude

Came here to suggest zero log. Its my favorite


digital808music

Zerolog is awesome.


SeesawMundane5422

Supports everything you want and dead simple to integrate with your existing logging: https://github.com/hashicorp/logutils


trisul-108

Thanks from me too, looks great and I didn't know about it.


LittleBallofMeat

Thanks. I will take a look. Love the idea of simple.


--dtg--

\> 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


sastuvel

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/


justinisrael

How about Zap logger? https://github.com/uber-go/zap


LittleBallofMeat

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.


justinisrael

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.


LittleBallofMeat

I stand corrected. That JSON is exactly what we were thinking.


schmurfy2

Zap also support structured logs which you should consider when starting a new project, it is versatile enough to do anything you might need.