Skip to content

Commit 9bd170f

Browse files
committed
docs: update logging documentation for clarity and formatting
1 parent d00860a commit 9bd170f

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

docs/core/logging.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ When debugging in non-production environments, you can instruct Logger to log th
446446
parameter or via `POWERTOOLS_LOGGER_LOG_EVENT` environment variable.
447447

448448
!!! 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.
450450

451451
=== "Function.cs"
452452

@@ -471,8 +471,8 @@ You can set a Correlation ID using `CorrelationIdPath` parameter by passing
471471
a [JSON Pointer expression](https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-json-pointer-03){target="_blank"}.
472472

473473
!!! 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.
476476

477477
=== "Function.cs"
478478

@@ -577,8 +577,8 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
577577
## Appending additional keys
578578

579579
!!! 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).
582582

583583
You can append your own keys to your existing logs via `AppendKey`. Typically this value would be passed into the
584584
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
683683
log statement.
684684

685685
!!! 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.
687687

688688
=== "Function.cs"
689689

@@ -782,8 +782,8 @@ You can dynamically set a percentage of your logs to **DEBUG** level via env var
782782
via `SamplingRate` parameter on attribute.
783783

784784
!!! 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.
787787

788788
=== "Sampling via attribute parameter"
789789

@@ -915,18 +915,18 @@ We support the following log levels:
915915
### Using AWS Lambda Advanced Logging Controls (ALC)
916916

917917
!!! 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.
920920

921921
With [AWS Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced)
922922
{target="_blank"}, you can enforce a minimum log level that Lambda will accept from your application code.
923923

924924
When enabled, you should keep `Logger` and ALC log level in sync to avoid data loss.
925925

926926
!!! 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 = )]`**
930930

931931
Here's a sequence diagram to demonstrate how ALC will drop both `Information` and `Debug` logs emitted from `Logger`,
932932
when ALC log level is stricter than `Logger`.
@@ -985,8 +985,8 @@ customize the serialization of Powertools Logger.
985985
This is useful when you want to change the casing of the property names or use a different naming convention.
986986

987987
!!! 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`.
990990

991991
```csharp
992992
builder.Logging.AddPowertoolsLogger(options =>
@@ -999,6 +999,19 @@ builder.Logging.AddPowertoolsLogger(options =>
999999
});
10001000
```
10011001

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+
10021015
### Custom Log formatter (Bring Your Own Formatter)
10031016

10041017
You can customize the structure (keys and values) of your log entries by implementing a custom log formatter and

0 commit comments

Comments
 (0)