You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Using AWS Lambda Advanced Logging Controls (ALC)
74
+
75
+
With [AWS Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced), you can control the output format of your logs as either TEXT or JSON and specify the minimum accepted log level for your application. Regardless of the output format setting in Lambda, Powertools for AWS Lambda will always output JSON formatted logging messages.
76
+
77
+
When you have this feature enabled, log messages that don’t meet the configured log level are discarded by Lambda. For example, if you set the minimum log level to WARN, you will only receive WARN and ERROR messages in your AWS CloudWatch Logs, all other log levels will be discarded by Lambda.
78
+
79
+
!!! warning "When using AWS Lambda Advanced Logging Controls (ALC)"
80
+
- When Powertools Logger output is set to `PascalCase`**`Level`** property name will be replaced by **`LogLevel`** as a property name.
81
+
- ALC takes precedence over **`POWERTOOLS_LOG_LEVEL`** and when setting it in code using **`[Logging(LogLevel = )]`**
82
+
83
+
```mermaid
84
+
sequenceDiagram
85
+
title Lambda ALC allows WARN logs only
86
+
participant Lambda service
87
+
participant Lambda function
88
+
participant Application Logger
89
+
90
+
Note over Lambda service: AWS_LAMBDA_LOG_LEVEL="WARN"
Logger will automatically listen for the AWS_LAMBDA_LOG_FORMAT and AWS_LAMBDA_LOG_LEVEL environment variables, and change behaviour if they’re found to ensure as much compatibility as possible.
103
+
104
+
**Priority of log level settings in Powertools for AWS Lambda**
105
+
106
+
When the Advanced Logging Controls feature is enabled, we are unable to increase the minimum log level below the AWS_LAMBDA_LOG_LEVEL environment variable value, see [AWS Lambda service documentation](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-log-level) for more details.
107
+
108
+
We prioritise log level settings in this order:
109
+
110
+
1. AWS_LAMBDA_LOG_LEVEL environment variable
111
+
2. Setting the log level in code using `[Logging(LogLevel = )]`
112
+
3. POWERTOOLS_LOG_LEVEL environment variable
113
+
114
+
In the event you have set POWERTOOLS_LOG_LEVEL to a level lower than the ACL setting, Powertools for AWS Lambda will output a warning log message informing you that your messages will be discarded by Lambda.
115
+
116
+
72
117
## Standard structured keys
73
118
74
119
Your logs will always include the following keys to your structured logging:
$"Current log level ({_logLevel}) does not match AWS Lambda Advanced Logging Controls minimum log level ({_lambdaLogLevel}). This can lead to data loss, consider adjusting them.";
0 commit comments