pythondjangopython-3.xloggingdjango-logging

What is Wrong with my Django logging configuration? No logs are seen in the log file


LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
            'style': '{',
        },
        'simple': {
            'format': '{levelname} {message}',
            'style': '{',
        },
    },
    'handlers': {
        'server_logger': {
            'level': 'DEBUG',
            'class':'logging.handlers.RotatingFileHandler',
            'maxBytes': 1024*1024*100,
            'backupCount': 20,
            'filename': os.path.join(BASE_DIR, 'server.log'),
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['server_logger'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

What is wrong with the above configuration and why don't I see my logs? Any thoughts?


Solution

  • Use the empty string '' as the key under 'loggers' to mark that as the root logger and capture messages from all loggers.