-
Notifications
You must be signed in to change notification settings - Fork 4
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
Removing the LoggerBackends.Console at runtime does not work #6
Comments
I suspect the reason it doesn't disable the console logging is that you still have the default handler active; the So the proper way to disable the console logging and to enable your own backend would be something like this in your config :logger,
default_handler: false,
level: :info # important - logs below this level will be ignored globally for all backends
config :logger, LoggerBackends.YourLogger,
option1: value1,
option2: value2 |
Thanks for the pointer. Does this mean the default handler is distinct from the LoggerBackends.Console? Or does it mean that it is started/added in a different way and therefore not controlled/controllable by LoggerBackends? If the latter, wouldn't it be better to unify this and have the default_handler be controlled through LoggerBackends as well? |
Yes, the default handler is distinct from From what I understand, it's mostly given as an example. I did found a use case for it, which is when you want to log to console only higher priority logs (e.g., In this case, you can't simply use the default console logger, as setting its level to PS. All the above is not the absolute truth, but just my understanding of the topic; I might be completely wrong. |
Just a quick add-on that the easiest way to remove the default logger would be to just :logger.remove_handler(:default) |
I am trying to disable the Console backend at runtime (and replace it with my own backend), but that does not seem to work and the application continues logging to the console. I am using:
I also tried passing
:console
andLogger.Backends.Console
The text was updated successfully, but these errors were encountered: