9

In my django project I have following LOGGING config:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'verbose': {
            'format': '%(name)s %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class':'django.utils.log.NullHandler',
        },
        'sentry': {
            'level': 'DEBUG',
            'class': 'sentry.client.handlers.SentryHandler',
            'formatter': 'verbose'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': False,
        },
        '': {
            'level': 'ERROR',
            'handlers': ['console'],
        },
    },
}

When running manage.py migrate I still have a lot of debug stuff in console, e.g:

DEBUG south 2011-08-08 11:22:23,847 generic 19539 140735078710464 south execute "..."

I'm expecting only error messages in console as I set root logger level to ERROR. What am I doing wrong?

UPDATE

Looks like problem is in south.logger module:

import sys
import logging
from django.conf import settings

# Create a dummy handler to use for now.
class NullHandler(logging.Handler):
    def emit(self, record):
        pass

_logger = logging.getLogger("south")
_logger.addHandler(NullHandler())
_logger.setLevel(logging.DEBUG)

After removing _logger.setLevel(logging.DEBUG) logging works as expected.

Can someone explain me such weird behavior?

1
  • +1 so other library developers can learn what not to do Commented Aug 10, 2011 at 22:39

1 Answer 1

12

The South developers shouldn't really be setting its top level logger level to DEBUG. In fact if they don't set it at all, it would inherit the root logger's level, which is normally defined by the application developer (which I guess is you, in this case).

I would suggest you report this as a bug on the relevant South forum.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.