def on_failure(self, exc, task_id, args, kwargs, einfo):
        """
        Capture the exception that caused the task to fail, if any.
        """
        log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
        super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
Capture the exception that caused the task to fail, if any.