scythargon
scythargon

Reputation: 3491

django logging "No handlers could be found for logger"

I've searched over all the similar questions, and nothing helped. I've created the 'universal' logger like this:

'': {
    'handlers': ['logfile','console'],
    'level': 'WARNING',
    'propagate': True,
},

in order to be able to write

import logging
log = logging.getLogger(__name__)

and get logger in any file of my django-application(seen this approach somewhere on SO), and several days ago it was working for me, but not now and I could not understand why.

There is my whole logging-settings:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            'datefmt' : "%d/%b/%Y %H:%M:%S"
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        },
       'logfile': {
            'level':'WARNING',
            'class':'logging.handlers.RotatingFileHandler',
            'filename': "/opt/telefacer_1/var/log/inapplog",
            'maxBytes': 50000,
            'backupCount': 2,
            'formatter': 'standard',
        },
        'console':{
            'level':'WARNING',
            'class':'logging.StreamHandler',
            'formatter': 'simple'
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        '': {
            'handlers': ['logfile','console'],
            'level': 'WARNING',
            'propagate': True,
        },
    }
}

Upvotes: 3

Views: 5127

Answers (1)

Aaron Caito
Aaron Caito

Reputation: 98

I see references to both a simple and standard formatter though only standard is defined.

Upvotes: 1

Related Questions