Skip to content
Snippets Groups Projects
Commit 8d7b000d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '713-celery-does-not-honour-logging-configuration' into 'master'

Resolve "Celery does not honour logging configuration"

Closes #713

See merge request !1067
parents 4678452f 45472d4b
No related branches found
No related tags found
1 merge request!1067Resolve "Celery does not honour logging configuration"
Pipeline #81982 failed
......@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Fixed
~~~~~
* Celery's logging did not honour Django's logging level
`2.10.1`_ - 2022-07-24
----------------------
......
import logging
import os
from traceback import format_exception
from django.conf import settings
from celery import Celery
from celery.signals import task_failure
from celery.signals import setup_logging, task_failure
from .util.core_helpers import get_site_preferences
from .util.email import send_email
......@@ -35,3 +36,9 @@ def task_failure_notifier(
"traceback": "".join(format_exception(type(exception), exception, traceback)),
},
)
@setup_logging.connect
def on_setup_logging(*args, **kwargs):
"""Load Django's logging configuration when running inside Celery."""
logging.config.dictConfig(settings.LOGGING)
......@@ -901,6 +901,12 @@ if not _settings.get("logging.disallowed_host", False):
"handlers": ["null"],
"propagate": False,
}
# Configure logging explicitly for Celery
LOGGING["loggers"]["celery"] = {
"handlers": ["console"],
"level": _settings.get("logging.level", "WARNING"),
"propagate": False,
}
# Rules and permissions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment