Skip to content

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

@georgeionita

Description

@georgeionita

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions