-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
In the production Lambda environment I am changing the format of the root logger.
Original format in aws lambda:
print(str( logging.getLogger('').handlers[0].formatter._fmt ))
#-> [%(levelname)s] %(asctime)s.%(msecs)dZ %(aws_request_id)s %(message)s
Format I changed:
formatter = logging.Formatter(
fmt='%(asctime)s.%(msecs)03d [%(aws_request_id)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s\n',
datefmt='%Y-%m-%d %H:%M:%S'
)
handler = logging.getLogger('').handlers[0]
handler.setFormatter(formatter)
and when this script is executed, the following error occurs.
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib64/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/lib64/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/lib64/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/lib64/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/lib64/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'aws_request_id'
Sorry for the report only.
Metadata
Metadata
Assignees
Labels
No labels