@@ -141,16 +141,24 @@ def __init__(
141141 config_recv: The receiver to listen for configuration changes.
142142 log_format: Use the specified format string in logs.
143143 log_datefmt: Use the specified date/time format in logs.
144+
145+ Note:
146+ log_format and log_datefmt are passed to the `logging.basicConfig`
147+ function. If any call to `logging.basicConfig` is made before this
148+ actor is created, then this actor will not override it.
144149 """
145150 super ().__init__ ()
146151 self ._config_recv = config_recv
147- self ._format = log_format
148- self ._datefmt = log_datefmt
149152
150153 # Setup default configuration.
151154 # This ensures logging is configured even if actor fails to start or
152155 # if the configuration cannot be loaded.
153156 self ._current_config : LoggingConfig = LoggingConfig ()
157+
158+ logging .basicConfig (
159+ format = log_format ,
160+ datefmt = log_datefmt ,
161+ )
154162 self ._update_logging (self ._current_config )
155163
156164 async def _run (self ) -> None :
@@ -176,11 +184,10 @@ def _update_logging(self, config: LoggingConfig) -> None:
176184 logging .getLogger (logger_id ).setLevel (logging .NOTSET )
177185
178186 self ._current_config = config
179- logging .basicConfig (
180- format = self ._format ,
181- level = self ._current_config .root_logger .level ,
182- datefmt = self ._datefmt ,
187+ _logger .debug (
188+ "Setting root logger level to '%s'" , self ._current_config .root_logger .level
183189 )
190+ logging .getLogger ().setLevel (self ._current_config .root_logger .level )
184191
185192 # For each logger in the new config, set the log level
186193 for logger_id , logger_config in self ._current_config .loggers .items ():
0 commit comments