# Fix Django ValueError: Unable to Configure Handler Loggers

> Resolve the Django logging ValueError by moving the loggers dictionary to a top-level key in the LOGGING configuration instead of nesting it under handlers

**URL:** https://sentry.io/answers/django-valueerror-unable-to-configure-handle-loggers/

---

## The Problem

You are trying to configure logging for your Django application, but keep getting the following error message:

```
ValueError: Unable to configure handler 'loggers'
```

This is your logging configuration dictionary in `settings.py`:

```python
import os

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "root": {
        "handlers": ["console"],
        "level": "WARNING",
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
        },
        "loggers": {
            "django": {
                "handlers": ["console"],
                "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
                "propagate": False,
            },
        },
    },
}
```

What is the cause of this error and how do you fix it?

## The Solution

The error is caused by a mistake in the structure of the logging dictionary. In the dictionary above, `loggers` is an element of `handlers`, but it should be a top-level element, per the [Django documentation](https://docs.djangoproject.com/en/5.2/topics/logging/#topic-logging-parts-loggers). A bare-bones `LOGGING` dictionary should be structured as follows:

```python
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        # add formatters here (optional)
    },
    'handlers': {
        # add handlers here
    },
    'loggers': {
        # add loggers here
    },
}
```

Here is a correctly indented version of the `LOGGING` dictionary:

```python
import os

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "root": {
        "handlers": ["console"],
        "level": "WARNING",
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
        },
    },
    "loggers": {
        "django": {
            "handlers": ["console"],
            "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
            "propagate": False,
        },
    },
}
```

---

*Source: [sentry.io/answers/django-valueerror-unable-to-configure-handle-loggers/](https://sentry.io/answers/django-valueerror-unable-to-configure-handle-loggers/)*
