Closed
Description
Hi!
I am using the aws-lambda-powertools-python
logger for a number of projects but also have existing deployments using structured JSON logging implemented with a custom logger. Our custom logger supports the Python logging extra
parameter to supply custom attributes. It would be great if the aws-lambda-powertools-python
formatter supported custom attributes so we can take advantage of structured logging for additional attributes.
Example
from aws_lambda_powertools.logging import Logger
logger = Logger()
logger.info('Put aggregation result', extra={'key': 'results/sum.csv', 'size': 130425})
Current output:
{
"level": "INFO",
"location": "<module>:5",
"message": "Put aggregation result",
"timestamp": "2020-12-23 11:00:47,695",
"service": "service_undefined",
"sampling_rate": 0
}
Desired output:
{
"level": "INFO",
"location": "<module>:5",
"message": "Put aggregation result",
"timestamp": "2020-12-23 11:00:47,695",
"service": "service_undefined",
"sampling_rate": 0,
"key": "results/sum.csv",
"size": 130425
}
This enables us to do effective log queries, filtering and stats using CloudWatch Logs Insights.
For reference:
python-json-logger
support custom attributes usingextra
- https://github.com/madzak/python-json-logger- Usage of the
extra
keyword argument to add custom attributes to theLogRecord
is covered here: https://docs.python.org/3/library/logging.html
Is this something that you would consider supporting?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage