Skip to content

Bug: CloudWatch logs do not use same logging level as PowerTools #783

Closed
@nCubed

Description

@nCubed

Expected Behaviour

When the logs are written to CloudWatch, the logging level is only applied at the structured logging. The CloudWatch logs have a different log level.

For example, when log level is set to "Error" with PowerTools, the CloudWatch log remains at "info". This is the same for all logging levels.

The issue here is that when our logs are ingested by company-wide logging aggregator (DataDog), the logs now are tagged with both "Error" and "info".

Is there a way to coerce the CloudWatch logging level to align with the PowerTools logging level?

Current Behaviour

2025-02-24T13:36:06.483Z	f6e6096f-5d28-57bd-99a3-6959252efdd6	info
{
    "cold_start": false,
    "xray_trace_id": "1-67bc<snip>",
    "function_name": "<snip>",
    "function_version": "$LATEST",
    "function_memory_size": 350,
    "function_arn": "arn:aws:lambda:us-east-2:<snip>",
    "function_request_id": "f6e6096f-<snip>",
    "timestamp": "2025-02-24T13:36:06.4837199Z",
    "level": "Error",
    "service": "<snip>",
    "name": "AWS.Lambda.Powertools.Logging.Logger",
    "message": "<snip>"
}

Code snippet

Use any standard logging message.

Possible Solution

No response

Steps to Reproduce

Log an event as an "Error". Json output is correctly set at "Error". CloudWatch is set at "info".

Powertools for AWS Lambda (.NET) version

latest

AWS Lambda function runtime

dotnet8

Debugging logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/loggingCore logging utilitybugUnexpected, reproducible and unintended software behaviourneed-more-informationMissing information before making any callspending-releaseFix or implementation already in dev waiting to be released

    Type

    No type

    Projects

    Status

    👀 In review

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions