Disable debug logging for django.db.backends?

2,088 views
Skip to first unread message

diafygi

unread,
May 24, 2011, 12:32:42 AM5/24/11
to Django users
Howdy all,

I have DEBUG=True in my settings.py, and I have several logging
entries in my project (Django 1.3)

However, when I am testing, there are tons of django.db.backends debug
entries that appear, and my logs gets lost in the shuffle.

Is there a way to disable django.db.backends in my settings.py? What
is an example?

Thanks,
Daniel

Nathan Duthoit

unread,
May 30, 2011, 1:11:25 PM5/30/11
to Django users
It's more of a hack than a clean solution but it works. Add the
following to your settings file:

import logging
logging.getLogger('django.db.backends').setLevel(logging.ERROR)

Malcolm Box

unread,
Jun 2, 2011, 7:56:19 AM6/2/11
to django...@googlegroups.com
Alternatively, configure your logging handlers to send the db logging somewhere else (ie another file), and not to pass it on.

So in settings.py have:

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file_logging': {
'level' : 'DEBUG',
'class' : 'logging.handlers.RotatingFileHandler',
'backupCount' : 5,
'maxBytes': 5000000,
'filename': 'django.log'
},
'db_logging': {
'level' : 'DEBUG',
'class' : 'logging.handlers.RotatingFileHandler',
'backupCount' : 5,
'maxBytes': 5000000,
'filename': 'django-db.log'
},
},

'loggers': {
'django' : {
'handlers': ['file_logging'],
'level' : 'DEBUG',
'propagate' : False,
},
'django.db' : {
'handlers' : ['db_logging'],
'level' : 'DEBUG',
'propagate': False,
},
}

Which should send your db logs just to the django-db.log file.

HTH,

Malcolm

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

Reply all
Reply to author
Forward
0 new messages