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(...) .
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 propertylevel(notlog_level). Lambda will assign the log output the levelINFOto messages with missing (or invalid)levelproperty, i.e. all messages created by the awslambdaric functionlog_errorare no longer considered errors because the propertylog_levelis 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 levelINFO.We should either add the property
levelto theerror_resultor replace the propertylog_levelwithlevelin theerror_resultcreated bylog_error(...).