You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by nimish-salve May 15, 2023 aws-lambda-powertools version: 2.15.0
I am trying logger to use 2 handlers.
FileHandler
Streamhandler
When I added extra keys via append_keys, newly registered handlers are not logging extra keys.
Sample code below:
import logging
from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging.formatter import LambdaPowertoolsFormatter
file_handler = logging.FileHandler('logs.log')
_LOGGER = Logger(service="test", level=logging.INFO, logger_handler=logging.NullHandler())
#_LOGGER = Logger(service="test", level=logging.INFO, logger_handler=file_handler) # this works
def main():
file_handler.setFormatter(LambdaPowertoolsFormatter())
_LOGGER.addHandler(file_handler)
_LOGGER.append_keys(test="test")
_LOGGER.info("in main 1")
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(LambdaPowertoolsFormatter())
_LOGGER.addHandler(stream_handler)
_LOGGER.info("in main 2")
if __name__ == "__main__":
main()
Whats could be the issue?
This is reproducible even with just 1 handler. If we register the handler while creating the logger itself, it works without any issues. When we explicitly register the handler, it does not work.
The text was updated successfully, but these errors were encountered:
Discussed in #2261
Originally posted by nimish-salve May 15, 2023
aws-lambda-powertools version: 2.15.0
I am trying logger to use 2 handlers.
When I added extra keys via append_keys, newly registered handlers are not logging extra keys.
Sample code below:
Whats could be the issue?
This is reproducible even with just 1 handler. If we register the handler while creating the logger itself, it works without any issues. When we explicitly register the handler, it does not work.
The text was updated successfully, but these errors were encountered: