Skip to content

Commit 1bcce19

Browse files
authored
Merge pull request #523 from hjgraca/update-examples-182
chore: update examples for 1.8.2 release
2 parents c7fe319 + fbabf2b commit 1bcce19

File tree

7 files changed

+19
-15
lines changed

7 files changed

+19
-15
lines changed

docs/core/logging.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@ Here is an example using the AWS SAM [Globals section](https://docs.aws.amazon.c
7272

7373
### Using AWS Lambda Advanced Logging Controls (ALC)
7474

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.
75+
!!! question "When is it useful?"
76+
When you want to set a logging policy to drop informational or verbose logs for one or all AWS Lambda functions, regardless of runtime and logger used.
7677

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+
With [AWS Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced){target="_blank"}, you can enforce a minimum log level that Lambda will accept from your application code.
79+
80+
When enabled, you should keep `Logger` and ALC log level in sync to avoid data loss.
7881

7982
!!! warning "When using AWS Lambda Advanced Logging Controls (ALC)"
8083
- When Powertools Logger output is set to `PascalCase` **`Level`** property name will be replaced by **`LogLevel`** as a property name.
8184
- ALC takes precedence over **`POWERTOOLS_LOG_LEVEL`** and when setting it in code using **`[Logging(LogLevel = )]`**
8285

86+
Here's a sequence diagram to demonstrate how ALC will drop both `Information` and `Debug` logs emitted from `Logger`, when ALC log level is stricter than `Logger`.
87+
8388
```mermaid
8489
sequenceDiagram
8590
title Lambda ALC allows WARN logs only
@@ -88,6 +93,7 @@ sequenceDiagram
8893
participant Application Logger
8994
9095
Note over Lambda service: AWS_LAMBDA_LOG_LEVEL="WARN"
96+
Note over Application Logger: POWERTOOLS_LOG_LEVEL="DEBUG"
9197
Lambda service->>Lambda function: Invoke (event)
9298
Lambda function->>Lambda function: Calls handler
9399
Lambda function->>Application Logger: Logger.Warning("Something happened")
@@ -99,20 +105,18 @@ sequenceDiagram
99105
Lambda service->>CloudWatch Logs: Ingest error logs
100106
```
101107

102-
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-
104108
**Priority of log level settings in Powertools for AWS Lambda**
105109

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-
108110
We prioritise log level settings in this order:
109111

110112
1. AWS_LAMBDA_LOG_LEVEL environment variable
111113
2. Setting the log level in code using `[Logging(LogLevel = )]`
112114
3. POWERTOOLS_LOG_LEVEL environment variable
113115

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.
116+
If you set `Logger` level lower than ALC, we will emit a warning informing you that your messages will be discarded by Lambda.
115117

118+
> **NOTE**
119+
> With ALC 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){target="_blank"} for more details.
116120
117121
## Standard structured keys
118122

examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
1010
<PackageReference Include="AWS.Lambda.Powertools.BatchProcessing" Version="0.0.1-preview" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
1313
</ItemGroup>
1414
</Project>

examples/Idempotency/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
1111
<PackageReference Include="AWS.Lambda.Powertools.Idempotency" Version="0.2.2-preview" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
1313
</ItemGroup>
1414
</Project>

examples/Logging/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
1212
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1313
</ItemGroup>
1414
</Project>

examples/Metrics/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.4.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.5.3" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1414
</ItemGroup>
1515
</Project>

examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="8.1.0" />
16-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
17-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.4.3" />
16+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
17+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.5.3" />
1818
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.3.2" />
1919
</ItemGroup>
2020
</Project>

examples/Tracing/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.3.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
1212
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.3.2" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1414
</ItemGroup>

0 commit comments

Comments
 (0)