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
**Service** | Sets **Service** key that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `Service`
30
30
**Logging level** | Sets how verbose Logger should be (Information, by default) | `POWERTOOLS_LOG_LEVEL` | `LogLevel`
31
31
32
-
!!! warning "When using Lambda Log Format JSON"
33
-
- And Powertools Logger output is set to `PascalCase`**`Level`** property name will be replaced by **`LogLevel`** as a property name.
34
-
- The Lambda Application log level setting will control what is sent to CloudWatch. It takes precedence over **`POWERTOOLS_LOG_LEVEL`** and when setting it in code using **`[Logging(LogLevel = )]`**
35
-
36
32
### Example using AWS Serverless Application Model (AWS SAM)
37
33
38
34
You can override log level by setting **`POWERTOOLS_LOG_LEVEL`** environment variable in the AWS SAM template.
@@ -73,6 +69,51 @@ Here is an example using the AWS SAM [Globals section](https://docs.aws.amazon.c
### 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 logger.setLevel()
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
+
76
117
## Standard structured keys
77
118
78
119
Your logs will always include the following keys to your structured logging:
0 commit comments