Hello.
I've noticed that when I have Django Toolbar enabled I'm not getting error messages on the console from runserver under my development machine.
Is this some kind of incompatibility between the two? (I'm creating this task because recently there was some work regarding logging here, but please let me know if this is a problem with django_toolbar package)
I was able to reproduce under a clean project, with only channels and debug_toolbar installed.
I've made a video to better demonstrate this. I intentionally put a non defined variable on the connect() method just to crash: https://streamable.com/veo2s
Here are my packages:
channels==2.1.5
daphne==2.2.3
Django==2.1.3
And my test project (a basic Django startapp):
test.zip
It might be that it's intercepting the logging in a weird way. How far do you have to remove Debug Toolbar before the problem goes away? Does removing the middleware fix it, or do you need to remove it from INSTALLED_APPS or uninstall it?
Either way, this might end up being a bug they have to fix, not us, just want to work out where it is.
It might be that it's intercepting the logging in a weird way. How far do you have to remove Debug Toolbar before the problem goes away? Does removing the middleware fix it, or do you need to remove it from INSTALLED_APPS or uninstall it?
It only goes away if I remove it from INSTALLED_APPS and urls.py (path('__debug__/', include(debug_toolbar.urls)).
All other combinations (INSTALLED_APPS, MIDDLEWARES, url.py) result on no logs being printed on console.
BTW thanks for the response 馃榿
The django-debug-toolbar issue tracker contains several logging-related issues:
https://github.com/jazzband/django-debug-toolbar/issues?utf8=%E2%9C%93&q=+is%3Aopen++logging
It's not my itch to scratch, but if you want to contribute to django-debug-toolbar I'm happy to help out with reviewing the change (and merging&releasing if you find a good fix)
This is related with my issue #1177. I was getting so frustrated over this.
Finally, I solved it by using the following LOGGING configuration:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django': {},
},
'root': {
'handlers': ['console', ],
'level': 'INFO'
},
}
But still I do not know exactly why it works :)
Source: https://medium.com/@saulshanabrook/simple-django-logging-ffa74c9ca0fc
OK, I'm afraid I think this might be a django-debug-toolbar issue, not a Channels issue, sorry! If you can find something in Channels we can fix that would re-enable it then let me know, but it would appear to be on the other end - I suspect the disable_existing_loggers on the recent code snippet is what is "fixing" it there.