Skip to content

Bug: Logs populating into cloudwatch as multiple lines instead of a single object #3763

Closed
@thault

Description

@thault

Expected Behaviour

I'm expecting the logs to populate as a single json object in cloudwatch.

expected

Current Behaviour

Logger logs are shown as single lines within cloudwatch creating a lot of lines within the log stream. I have tried the log format as text and JSON and get the issue both ways.

actual

Code snippet

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
logger = Logger(log_uncaught_exceptions=True)

@logger.inject_lambda_context(log_event=True)
def lambda_handler(event, context)
    logger.info("Token retrieval started")

Possible Solution

No response

Steps to Reproduce

Lambda using the powertools layer arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:60, followed the guide for basic logging with context included. All logs created via logger.info() or logger.debug() have the issue.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

Lambda Layers

Debugging logs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions