-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change log level dynamically #252
Comments
I need this feature because zero-log is used as the underlying library. zero-log assumes people will set the level first. |
I've achieved this in a HTTP service by setting the log level in the logger that is created for each request (which also carries all the per-request metadata like request ID). This wouldn't work if you need to change log level mid-request, but I'm yet to find that a problem for a typical HTTP service, which deals with short-lived individual requests. |
For us would be use case - our application has API and background processes or shared services that log. During application start logger is created as very first thing. during application startup application configuration is also read in and it could/should be able to change log level. |
Store the logger as a pointer with proper locking and change the logger as you please. |
In |
I have made #583 to suggest that zerolog needs a batching post-processing capability for (possibly a batch of) log events before they are written out. This would allow one to decide the log level after observing what other log events have been generated for example during request handling. You could then log at debug log level but write the log line only if any of the log lines for the request was an error, or something like that. |
What is wrong with calling |
Basically, title.
I want to be able to dynamically set the log level at runtime. Is this achievable with zerolog?
This can be done with zap. https://dev.to/procyclinsur/golang-dynamic-logging-3p7k
The text was updated successfully, but these errors were encountered: