Skip to content

Commit a5e6b09

Browse files
committed
Update docs with warning in MDC section as well.
1 parent f784886 commit a5e6b09

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/core/logging.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ To append additional keys in your logs, you can use the `StructuredArguments` cl
640640
}
641641
```
642642

643-
???+ warning "Warning"
643+
???+ warning "Do not use arguments with reserved keys"
644644
If the key name of your structured argument matches any of the [standard structured keys](#standard-structured-keys) or any of the [additional structured keys](#additional-structured-keys) the whole argument will be ignored. This is to protect you from accidentally overwriting reserved keys such as the log level or Lambda context information.
645645

646646
**Using MDC**
@@ -653,6 +653,9 @@ Mapped Diagnostic Context (MDC) is essentially a Key-Value store. It is supporte
653653
???+ warning "Custom keys stored in the MDC are persisted across warm invocations"
654654
Always set additional keys as part of your handler method to ensure they have the latest value, or explicitly clear them with [`clearState=true`](#clearing-state).
655655

656+
???+ warning "Do not add reserved keys to MDC"
657+
Avoid adding any of the keys listed in [standard structured keys](#standard-structured-keys) and [additional structured keys](#additional-structured-keys) to your MDC. This may cause unindented behavior and will overwrite the context set by Powertools. Unlike with StructuredArguments, Powertools will **not** ignore reserved keys set via MDC.
658+
656659

657660
### Removing additional keys
658661

0 commit comments

Comments
 (0)