This document describes the current stable version of Celery (5.4). For development docs, go here.


Logging utilities.

class celery.utils.log.ColorFormatter(fmt=None, use_color=True)[source]

Logging formatter that adds colors based on severity.

COLORS = {'black': <bound method of ''>, 'blue': <bound method of ''>, 'cyan': <bound method colored.cyan of ''>, 'green': <bound method of ''>, 'magenta': <bound method colored.magenta of ''>, 'red': <bound method of ''>, 'white': <bound method colored.white of ''>, 'yellow': <bound method colored.yellow of ''>}

Loglevel -> Color mapping.

colors = {'CRITICAL': <bound method colored.magenta of ''>, 'DEBUG': <bound method of ''>, 'ERROR': <bound method of ''>, 'WARNING': <bound method colored.yellow of ''>}

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.


Format and return the specified exception information as a string.

This default implementation just uses traceback.print_exception()

class celery.utils.log.LoggingProxy(logger, loglevel=None)[source]

Forward file object to logging.Logger instance.

  • logger (Logger) – Logger instance to forward to.

  • loglevel (int, str) – Log level to use when logging messages.

closed = False

Here for file support.

loglevel = 40
mode = 'w'
name = None
write(data: AnyStr) int[source]

Write message to logging object.

writelines(sequence: Sequence[str]) None[source]

Write list of strings to file.

The sequence can be any iterable object producing strings. This is equivalent to calling write() for each string.


Get logger by name.


Return the multiprocessing logger.


Get logger for task module by name.


Context that records that we are in a signal handler.


Convert level name/int to log level.


Reset multiprocessing logging setup.


Set flag signifiying that we’re inside a signal handler.