Question: how do I disable Celery Task received/succeeded log messages
jpells opened this issue · 1 comments
jpells commented
I would like to disable the Celery Task received/succeeded log messages but only for health_check.contrib.celery.tasks.add
. Is there a setting available for this?
Thank you for your help.
jpells commented
The following is how I disabled logs for the Celery health check
import logging
from celery.signals import after_setup_logger
class HealthCheckFilter(logging.Filter):
def filter(self, record):
return "health_check.contrib.celery.tasks.add" not in record.getMessage()
@after_setup_logger.connect
def on_after_setup_logger(**kwargs):
# Logger used for Task Received
logger = logging.getLogger("celery.worker.strategy")
logger.addFilter(HealthCheckFilter())
# Logger used for Task Succeeded
logger = logging.getLogger("celery.app.trace")
logger.addFilter(HealthCheckFilter())