Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library logging does not work with AWS Lambda Power Tools #36

Open
georgeionita opened this issue Dec 28, 2022 · 0 comments
Open

Library logging does not work with AWS Lambda Power Tools #36

georgeionita opened this issue Dec 28, 2022 · 0 comments

Comments

@georgeionita
Copy link

Per the lambda best practices, trying to enable structured logging
https://awslabs.github.io/aws-lambda-powertools-python/2.5.0/core/logger/#how-can-i-enable-powertools-logging-for-imported-libraries

from aws_lambda_powertools.logging.logger import Logger
from aws_lambda_powertools.logging import utils

logger = Logger(service='appFlow_Connector')

utils.copy_config_to_registered_loggers(source_logger=logger)

But because this line in the SDK does not specify a logger name and implicitly uses the root logger, the power tools configuration can't apply the logger configuration to it. Hence logs are output in text format rather than JSON.

def lambda_handler(self, event, context):
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant