config#

class litestar.logging.config.BaseLoggingConfig#

Bases: ABC

Abstract class that should be extended by logging configs.

log_exceptions: Literal['always', 'debug', 'never']#

Should exceptions be logged, defaults to log exceptions when app.debug == True

traceback_line_limit: int#

Max number of lines to print for exception traceback.

Deprecated since version 2.9.0: This parameter is deprecated and ignored. It will be removed in a future release.

exception_logging_handler: ExceptionLoggingHandler | None#

Handler function for logging exceptions.

abstract configure() GetLogger#

Return logger with the given configuration.

Returns:

A ‘logging.getLogger’ like function.

static set_level(logger: Any, level: int) None#

Provides a consistent interface to call setLevel for all loggers.

class litestar.logging.config.LoggingConfig#

Bases: BaseLoggingConfig

Configuration class for standard logging.

logging_module: str#

Logging module. logging and picologging are supported. picologging will be used by default if installed.

version: Literal[1] = 1#

The only valid value at present is 1.

incremental: bool = False#

Whether the configuration is to be interpreted as incremental to the existing configuration.

Notes

  • This option is ignored for ‘picologging’

disable_existing_loggers: bool = False#

Whether any existing non-root loggers are to be disabled.

filters: dict[str, dict[str, Any]] | None = None#

A dict in which each key is a filter id and each value is a dict describing how to configure the corresponding Filter instance.

propagate: bool = True#

If messages must propagate to handlers higher up the logger hierarchy from this logger.

Deprecated since version 2.10.0: This parameter is deprecated. It will be removed in a future release. Use propagate at the logger level.

formatters: dict[str, dict[str, Any]]#

A dict in which each key is a formatter and each value is a dict describing how to configure the corresponding Formatter instance. A standard formatter is provided.

handlers: dict[str, dict[str, Any]]#

A dict in which each key is a handler id and each value is a dict describing how to configure the corresponding Handler instance. Two handlers are provided, console and queue_listener.

loggers: dict[str, dict[str, Any]]#

A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance. A litestar logger is mandatory and will be configured as required.

root: dict[str, dict[str, Any] | list[Any] | str]#

This will be the configuration for the root logger.

Processing of the configuration will be as for any logger, except that the propagate setting will not be applicable.

configure_root_logger: bool = True#

Should the root logger be configured, defaults to True for ease of configuration.

log_exceptions: Literal['always', 'debug', 'never']#

Should exceptions be logged, defaults to log exceptions when ‘app.debug == True’

traceback_line_limit: int#

Max number of lines to print for exception traceback.

Deprecated since version 2.9.0: This parameter is deprecated and ignored. It will be removed in a future release.

exception_logging_handler: ExceptionLoggingHandler | None#

Handler function for logging exceptions.

configure() GetLogger#

Return logger with the given configuration.

Returns:

A ‘logging.getLogger’ like function.

static set_level(logger: Logger, level: int) None#

Provides a consistent interface to call setLevel for all loggers.

__init__(logging_module: str = <factory>, version: Literal[1] = 1, incremental: bool = False, disable_existing_loggers: bool = False, filters: dict[str, dict[str, Any]] | None = None, propagate: bool = True, formatters: dict[str, dict[str, Any]] = <factory>, handlers: dict[str, dict[str, Any]] = <factory>, loggers: dict[str, dict[str, Any]] = <factory>, root: dict[str, dict[str, Any] | list[Any] | str] = <factory>, configure_root_logger: bool = True, log_exceptions: Literal['always', 'debug', 'never'] = 'debug', traceback_line_limit: int = -1, exception_logging_handler: ExceptionLoggingHandler | None = None) None#
class litestar.logging.config.StructLoggingConfig#

Bases: BaseLoggingConfig

Configuration class for structlog.

Notes

  • requires structlog to be installed.

__init__(processors: list[Processor] | None = None, standard_lib_logging_config: LoggingConfig | None = None, wrapper_class: type[BindableLogger] | None = None, context_class: dict[str, Any] | None = None, logger_factory: Callable[..., WrappedLogger] | None = None, cache_logger_on_first_use: bool = True, log_exceptions: Literal['always', 'debug', 'never'] = 'debug', traceback_line_limit: int = -1, exception_logging_handler: ExceptionLoggingHandler | None = None, pretty_print_tty: bool = True) None#
processors: list[Processor] | None = None#

Iterable of structlog logging processors.

standard_lib_logging_config: LoggingConfig | None = None#

Optional customized standard logging configuration.

Use this when you need to modify the standard library outside of the Structlog pre-configured implementation.

wrapper_class: type[BindableLogger] | None = None#

Structlog bindable logger.

context_class: dict[str, Any] | None = None#

Context class (a ‘contextvar’ context) for the logger.

logger_factory: Callable[..., WrappedLogger] | None = None#

Logger factory to use.

cache_logger_on_first_use: bool = True#

Whether to cache the logger configuration and reuse.

log_exceptions: Literal['always', 'debug', 'never']#

Should exceptions be logged, defaults to log exceptions when ‘app.debug == True’

traceback_line_limit: int#

Max number of lines to print for exception traceback.

Deprecated since version 2.9.0: This parameter is deprecated and ignored. It will be removed in a future release.

exception_logging_handler: ExceptionLoggingHandler | None#

Handler function for logging exceptions.

pretty_print_tty: bool = True#

Pretty print log output when run from an interactive terminal.

configure() GetLogger#

Return logger with the given configuration.

Returns:

A ‘logging.getLogger’ like function.

static set_level(logger: Logger, level: int) None#

Provides a consistent interface to call setLevel for all loggers.