Skip to content

Commit 3823ef7

Browse files
committed
docs(logger): clarify Advanced Logging Controls interaction with sampling
1 parent 5496213 commit 3823ef7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/core/logger.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ We prioritise log level settings in this order:
409409
2. Explicit log level in `Logger` constructor, or by calling the `logger.setLevel()` method
410410
3. `POWERTOOLS_LOG_LEVEL` environment variable
411411

412+
!!! info "AWS CDK and Advanced Logging Controls"
413+
When using AWS CDK's `applicationLogLevelV2` parameter or setting log levels through the Lambda console, AWS Lambda automatically sets the `AWS_LAMBDA_LOG_LEVEL` environment variable. This means Lambda's log level takes precedence over Powertools for AWS configuration, potentially overriding both `POWERTOOLS_LOG_LEVEL` and sampling settings.
414+
415+
**Example**: If you set `applicationLogLevelV2=DEBUG` in CDK while having `POWERTOOLS_LOG_LEVEL=INFO`, the DEBUG level will be used because Lambda automatically sets the environment variable `AWS_LAMBDA_LOG_LEVEL` to the debug level.
416+
412417
If you set `Logger` level lower than ALC, we will emit a warning informing you that your messages will be discarded by Lambda.
413418

414419
> **NOTE**
@@ -825,6 +830,8 @@ Use sampling when you want to dynamically change your log level to **DEBUG** bas
825830

826831
You can use values ranging from `0.0` to `1` (100%) when setting `POWERTOOLS_LOGGER_SAMPLE_RATE` env var, or `sampling_rate` parameter in Logger.
827832

833+
**AWS Lambda Advanced Logging Controls (ALC)** settings can affect Sampling behavior. See [how it works](#aws-lambda-advanced-logging-controls-alc).
834+
828835
???+ tip "Tip: When is this useful?"
829836
Log sampling allows you to capture debug information for a fraction of your requests, helping you diagnose rare or intermittent issues without increasing the overall verbosity of your logs.
830837

0 commit comments

Comments
 (0)