zerolog icon indicating copy to clipboard operation
zerolog copied to clipboard

[Question] Is it possible to log context for only certain levels (ie: Warn and above)

Open KMFSousa opened this issue 4 years ago • 3 comments

I'm using the global logger, because it's cleaner and makes sense for this project.

I'd like to log.Logger = log.With().Str("identifier", identifier).Logger() however only have it print with log.Warn() and above. Is there a way to do this?

KMFSousa avatar Oct 26 '21 01:10 KMFSousa

Not with a single global logger.

rs avatar Oct 26 '21 02:10 rs

Is it possible to have multiple global loggers through the zerlog/log ? Or the solution is to just make a child logger of that and use it locally where we want to have the context

Alternatively, is this possible with not a global logger?

KMFSousa avatar Oct 26 '21 17:10 KMFSousa

You can have multiple global loggers but you will have to keep track of them by yourself.

rs avatar Oct 26 '21 18:10 rs