Skip to content

Error logging is incompatible with Lambda Advanced Logging Controls #202

@faberchri

Description

@faberchri

For Lambdas configured to log in JSON (_AWS_LAMBDA_LOG_FORMAT == LogFormat.JSON), error log messages contain the property "log_level": "ERROR". If the Lambda is configured to use log-level filtering the filtering doesn't work as expected because the log-level filtering feature makes the assumption that the message contains the JSON property level (not log_level). Lambda will assign the log output the level INFO to messages with missing (or invalid) level property, i.e. all messages created by the awslambdaric function log_error are no longer considered errors because the property log_level is simply ignored by Lambda.

Hence, if we use log-level filtering and set the level to WARN (a pretty common config for production) all error log messages created by awslambdaric (most notably uncaught handler errors) are missing in CloudWatch because they are wrongly attributed the (default) log level INFO.

We should either add the property level to the error_result or replace the property log_level with level in the error_result created by log_error(...) .

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