class sanic.compat.Header

Bases: CIMultiDict

Container used for both request and response headers. It is a subclass of CIMultiDict.

It allows for multiple values for a single key in keeping with the HTTP spec. Also, all keys are case in-sensitive.

Please checkout the MultiDict documentation for more details about how to use the object. In general, it should work very similar to a regular dictionary.


Convenience method mapped to getall().


key (str) –


enum sanic.log.Colors(value)

Bases: str, Enum

An enumeration.

Member Type


Valid values are as follows:

END = <Colors.END: '\x1b[0m'>
BOLD = <Colors.BOLD: '\x1b[1m'>
BLUE = <Colors.BLUE: '\x1b[34m'>
GREEN = <Colors.GREEN: '\x1b[32m'>
PURPLE = <Colors.PURPLE: '\x1b[35m'>
RED = <Colors.RED: '\x1b[31m'>
SANIC = <Colors.SANIC: '\x1b[38;2;255;13;104m'>
YELLOW = <Colors.YELLOW: '\x1b[01;33m'>
class sanic.log.VerbosityFilter(name='')

Bases: Filter


Determine if the specified record is to be logged.

Is the specified record to be logged? Returns 0 for no, nonzero for yes. If deemed appropriate, the record may be modified in-place.


record (LogRecord) –

Return type


sanic.log.LOGGING_CONFIG_DEFAULTS: Dict[str, Any] = {'disable_existing_loggers': False, 'formatters': {'access': {'class': 'logging.Formatter', 'datefmt': '[%Y-%m-%d %H:%M:%S %z]', 'format': '%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: %(request)s %(message)s %(status)d %(byte)d'}, 'generic': {'class': 'logging.Formatter', 'datefmt': '[%Y-%m-%d %H:%M:%S %z]', 'format': '%(asctime)s [%(process)d] [%(levelname)s] %(message)s'}}, 'handlers': {'access_console': {'class': 'logging.StreamHandler', 'formatter': 'access', 'stream': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>}, 'console': {'class': 'logging.StreamHandler', 'formatter': 'generic', 'stream': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>}, 'error_console': {'class': 'logging.StreamHandler', 'formatter': 'generic', 'stream': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>}}, 'loggers': {'sanic.access': {'handlers': ['access_console'], 'level': 'INFO', 'propagate': True, 'qualname': 'sanic.access'}, 'sanic.error': {'handlers': ['error_console'], 'level': 'INFO', 'propagate': True, 'qualname': 'sanic.error'}, 'sanic.root': {'handlers': ['console'], 'level': 'INFO'}, 'sanic.server': {'handlers': ['console'], 'level': 'INFO', 'propagate': True, 'qualname': 'sanic.server'}}, 'version': 1}

Defult logging configuration

sanic.log.access_logger = <Logger sanic.access (WARNING)>

Logger used by Sanic for access logging

sanic.log.error_logger = <Logger sanic.error (WARNING)>

Logger used by Sanic for error logging

sanic.log.logger = <Logger sanic.root (WARNING)>

General Sanic logger

sanic.log.server_logger = <Logger sanic.server (WARNING)>

Logger used by Sanic for server related messages