configure_pylog_MDC

lsst.log.configure_pylog_MDC(level: str, MDC_class: Optional[type] = <class 'lsst.log.log.logContinued.MDCDict'>)

Configure log4cxx to send messages to Python logging, with MDC support.

Parameters:
level : str

Name of the logging level for root log4cxx logger.

MDC_class : type, optional

Type of dictionary which is added to logging.LogRecord as an MDC attribute. Any dictionary or defaultdict-like class can be used as a type. If None the logging.LogRecord will not be augmented.

Notes

This method does two things:

  • Configures log4cxx with a given logging level and a PyLogAppender appender class which forwards all messages to Python logging.
  • Installs a record factory for Python logging that adds MDC attribute to every logging.LogRecord object (instance of MDC_class). This will happen by default but can be disabled by setting the MDC_class parameter to None.