diff --git a/aws_lambda_powertools/logging/formatter.py b/aws_lambda_powertools/logging/formatter.py index e35c9a7a327..246fa171d4e 100644 --- a/aws_lambda_powertools/logging/formatter.py +++ b/aws_lambda_powertools/logging/formatter.py @@ -222,7 +222,7 @@ def _extract_log_keys(self, log_record: logging.LogRecord) -> Dict[str, Any]: record_dict["asctime"] = self.formatTime(record=log_record, datefmt=self.datefmt) extras = {k: v for k, v in record_dict.items() if k not in RESERVED_LOG_ATTRS} - formatted_log = {**extras} + formatted_log = {} # Iterate over a default or existing log structure # then replace any std log attribute e.g. '%(level)s' to 'INFO', '%(process)d to '4773' @@ -233,6 +233,7 @@ def _extract_log_keys(self, log_record: logging.LogRecord) -> Dict[str, Any]: else: formatted_log[key] = value + formatted_log.update(**extras) return formatted_log @staticmethod