Logging Modules

logging.config

Configures loggers, handlers and formatters from declarative mappings or configuration files. dictConfig requires a schema version. Configuration may resolve and call Python objects, so accept only trusted configuration. The example validates an invalid version without changing global logging configuration.

Formal Syntax & Structure

python syntaxpython
import logging.config

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from logging.config import dictConfigtry:    dictConfig({"version": 2})except ValueError:    print("Invalid schema version")
Python Reference