@@ -446,7 +446,7 @@ When debugging in non-production environments, you can instruct Logger to log th
446
446
parameter or via ` POWERTOOLS_LOGGER_LOG_EVENT ` environment variable.
447
447
448
448
!!! warning
449
- Log event is disabled by default to prevent sensitive info being logged.
449
+ Log event is disabled by default to prevent sensitive info being logged.
450
450
451
451
=== "Function.cs"
452
452
@@ -471,8 +471,8 @@ You can set a Correlation ID using `CorrelationIdPath` parameter by passing
471
471
a [ JSON Pointer expression] ( https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-json-pointer-03 ) {target="_ blank"}.
472
472
473
473
!!! Attention
474
- The JSON Pointer expression is ` case sensitive ` . In the bellow example ` /headers/my_request_id_header ` would work but
475
- ` /Headers/my_request_id_header ` would not find the element.
474
+ The JSON Pointer expression is ` case sensitive ` . In the bellow example ` /headers/my_request_id_header ` would work but
475
+ ` /Headers/my_request_id_header ` would not find the element.
476
476
477
477
=== "Function.cs"
478
478
@@ -577,8 +577,8 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
577
577
## Appending additional keys
578
578
579
579
!!! info "Custom keys are persisted across warm invocations"
580
- Always set additional keys as part of your handler to ensure they have the latest value, or explicitly clear them with [
581
- ` ClearState=true ` ] ( #clearing-all-state ) .
580
+ Always set additional keys as part of your handler to ensure they have the latest value, or explicitly clear them with [
581
+ ` ClearState=true ` ] ( #clearing-all-state ) .
582
582
583
583
You can append your own keys to your existing logs via ` AppendKey ` . Typically this value would be passed into the
584
584
function via the event. Appended keys are added to all subsequent log entries in the current execution from the point
@@ -683,7 +683,7 @@ It accepts any dictionary, and all keyword arguments will be added as part of th
683
683
log statement.
684
684
685
685
!!! info
686
- Any keyword argument added using extra keys will not be persisted for subsequent messages.
686
+ Any keyword argument added using extra keys will not be persisted for subsequent messages.
687
687
688
688
=== "Function.cs"
689
689
@@ -782,8 +782,8 @@ You can dynamically set a percentage of your logs to **DEBUG** level via env var
782
782
via ` SamplingRate ` parameter on attribute.
783
783
784
784
!!! info
785
- Configuration on environment variable is given precedence over sampling rate configuration on attribute, provided it's
786
- in valid value range.
785
+ Configuration on environment variable is given precedence over sampling rate configuration on attribute, provided it's
786
+ in valid value range.
787
787
788
788
=== "Sampling via attribute parameter"
789
789
@@ -915,18 +915,18 @@ We support the following log levels:
915
915
### Using AWS Lambda Advanced Logging Controls (ALC)
916
916
917
917
!!! question "When is it useful?"
918
- When you want to set a logging policy to drop informational or verbose logs for one or all AWS Lambda functions,
919
- regardless of runtime and logger used.
918
+ When you want to set a logging policy to drop informational or verbose logs for one or all AWS Lambda functions,
919
+ regardless of runtime and logger used.
920
920
921
921
With [ AWS Lambda Advanced Logging Controls (ALC)] ( https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced )
922
922
{target="_ blank"}, you can enforce a minimum log level that Lambda will accept from your application code.
923
923
924
924
When enabled, you should keep ` Logger ` and ALC log level in sync to avoid data loss.
925
925
926
926
!!! warning "When using AWS Lambda Advanced Logging Controls (ALC)"
927
- - When Powertools Logger output is set to ` PascalCase ` ** ` Level ` ** property name will be replaced by ** ` LogLevel ` ** as
928
- a property name.
929
- - ALC takes precedence over ** ` POWERTOOLS_LOG_LEVEL ` ** and when setting it in code using ** ` [Logging(LogLevel = )] ` **
927
+ - When Powertools Logger output is set to ` PascalCase ` ** ` Level ` ** property name will be replaced by ** ` LogLevel ` ** as
928
+ a property name.
929
+ - ALC takes precedence over ** ` POWERTOOLS_LOG_LEVEL ` ** and when setting it in code using ** ` [Logging(LogLevel = )] ` **
930
930
931
931
Here's a sequence diagram to demonstrate how ALC will drop both ` Information ` and ` Debug ` logs emitted from ` Logger ` ,
932
932
when ALC log level is stricter than ` Logger ` .
@@ -985,8 +985,8 @@ customize the serialization of Powertools Logger.
985
985
This is useful when you want to change the casing of the property names or use a different naming convention.
986
986
987
987
!!! info
988
- If you want to preserve the original casing of the property names (keys), you can set the ` DictionaryKeyPolicy ` to
989
- ` null ` .
988
+ If you want to preserve the original casing of the property names (keys), you can set the ` DictionaryKeyPolicy ` to
989
+ ` null ` .
990
990
991
991
``` csharp
992
992
builder .Logging .AddPowertoolsLogger (options =>
@@ -999,6 +999,19 @@ builder.Logging.AddPowertoolsLogger(options =>
999
999
});
1000
1000
```
1001
1001
1002
+ !!! warning
1003
+ When using ` builder.Logging.AddPowertoolsLogger ` method it will use any already configured logging providers (file loggers, database loggers, third-party providers).
1004
+
1005
+ If you want to use Powertools Logger as the only logging provider, you should call ` builder.Logging.ClearProviders() ` before adding Powertools Logger or the new method override
1006
+
1007
+ ```csharp
1008
+ builder.Logging.AddPowertoolsLogger(config =>
1009
+ {
1010
+ config.Service = "TestService";
1011
+ config.LoggerOutputCase = LoggerOutputCase.PascalCase;
1012
+ }, clearExistingProviders: true);
1013
+ ```
1014
+
1002
1015
### Custom Log formatter (Bring Your Own Formatter)
1003
1016
1004
1017
You can customize the structure (keys and values) of your log entries by implementing a custom log formatter and
0 commit comments