-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Dash object adds handler to logger creating extra handler #756
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
Comments
I just ran into this bug, which caused my package level loggers to output everything in duplicate. I spent quite a while debugging it, since thought it was caused by Flask. I strongly agree with the idea of not adding logging handlers. What happened in my case was that my package already had a logger by |
A possible workaround is the following:
|
@RiccardoNizzolo yep that's how I work around it currently also, |
Working around it is easy once you figure out what's going on. But at least for me, that took quite a while. Please don't force logging handlers on us :) |
I'm annoyed that the team would do that, add a handler in this manner. Similar to @jjnurminen I spent hours and hours trying to nail down the cause. I didn't want to just remove handlers as a workaround until I figured out why I was getting so many messages ("Did I configure logging wrong?"). Don't get me wrong, love Dash for what it makes possible, which is a lot. But let's save other developers from this trouble. |
Bump this ticket as I see this ticket now after I created a ticket to JupyterDash plotly/jupyter-dash#61. While I think this issue is less obvious with Dash, it's obvious and annoying with JupyterDash as with Jupyterlab one could repeatedly run notebook cell that creates JuptyerDash object. |
I just hit this and like others had to spend a while to determine that dash was adding a sysout handler as its not expected that a library makes changes to your logging configuration. It's frustrating as it goes to std out without any formatting. Should use "logging.NullHandler()" to avoid warnings with a config to turn on if required. An example of how this is done better is the AWS library where NullHandler is used by default with the ability to add a handler is there if required. |
3 years later this is still not fixed... a library/package should not be setting up own handlers - this is responsibility of end-user application. At the very least that should be an opt-in for those who can't be bothered setting up their own handlers. |
Apologies for not providing a maintainer response to this issue before. We're really hardly using this logger. There's one debug log that we can probably just delete. The only one we care about is the one that displays the url we're serving on: Line 1949 in 5baac83
That message should definitely be displayed by default, but is there any reason not to just |
I would happily have my application break and have to remove my stupid hacks to |
I have tried all above mentioned workarounds. It doesn't work. As soon as I add my custom logger and FileHandler to it, very log starts to be duplicated. |
Hi,
Just ran into this issue that stems from the two conventions of
and the line
dash/dash/dash.py
Line 217 in 3a1a1c6
This results in an extra handler being added to the
__name__
logger which is presumably unwanted by the user.I think the convention is to add at most add a
logging.NullHandler()
handler to logging library/packages. From Configuring Logging for a Library section (though it's Python2 fyi), it states:When I have a moment I would be happy to try and open a small PR rectifying it if maintainers decide they would want to avoid adding logging handlers in Dash.
Nice one :)
The text was updated successfully, but these errors were encountered: