Closed ieugen closed 2 years ago
Yes, you can call dialog.logger/initialize!
to reload the configuration wholesale:
https://github.com/amperity/dialog/blob/10a22a24d4d21b8eb56fe08df3bf0843e2d75c22/src/clojure/dialog/logger.clj#L49-L51
To manage individual logger levels at runtime, use dialog.logger/set-level!
https://github.com/amperity/dialog/blob/10a22a24d4d21b8eb56fe08df3bf0843e2d75c22/src/clojure/dialog/logger.clj#L143-L146
We expose this as part of an administrative endpoint on our service instances, which also supports things like health checks and graceful shutdowns.
Configuration can be altered at runtime in two ways:
dialog.logger/initialize!
dialog.logger/set-level!
;; see current configuration
log/config
(log/initialize!)
(dialog.logger/set-level! "dev.start" :debug)
(dialog.logger/debug "Dialog info")
(clojure.tools.logging/debug "tools.logging info")
(dialog.logger/set-level! "dev.start" :info)
(dialog.logger/debug "Dialog info")
(clojure.tools.logging/debug "tools.logging info")
(dialog.logger/set-level! "com.zaxxer.hikari.util.DriverDataSource" :info)
Tooling for doing this at runtime can be constructed as an external functionality using these primitives.
Is there a way to update the logging configuration / levels at runtime without restarting the app?
I imagine this to be useful during long REPL sessions or even in production.
Is there a way to to the same by reloading the config on disk? This is for OPS where no repl is available / desired.
In unix ops the process is usually:
I think for dialog is enough to implement logic to apply configuration changes. Loading can happen on the client side.