[Doc] provide recommendation on log scopes (#5549)

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
This commit is contained in:
Reiley Yang 2024-04-18 10:05:09 -07:00 committed by GitHub
parent 266fe91bb8
commit 36ceb2efe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 3 deletions

View File

@ -14,9 +14,10 @@ TODO
### IncludeScopes
A "[scope](https://docs.microsoft.com/dotnet/core/extensions/logging#log-scopes)"
is an `ILogger` concept that can group a set of logical operations and attach
data to each log created as part of a set.
Log
[scope](https://docs.microsoft.com/dotnet/core/extensions/logging#log-scopes) is
an `ILogger` concept that can group a set of logical operations and attach data
to each log created as part of a set.
`IncludeScopes` is off by default. Setting this to `true` will include all
scopes with the exported `LogRecord`. Consult the individual `Exporter`
@ -24,6 +25,14 @@ docs to learn more about how scopes will be processed.
See [Program.cs](Program.cs) for an example.
> [!NOTE]
> When using [`ILogger.BeginScope<TState>(TState
state)`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger.beginscope),
it is highly recommended to use `IReadOnlyList<KeyValue<string, object?>>` or
`List<KeyValuePair<string, object?>>` as the `TState` for the best performance.
When performance is not a critical requirement,
`IEnumerable<KeyValuePair<string, object?>>` can be used.
### IncludeFormattedMessage
`IncludeFormattedMessage` indicates if the `LogRecord.FormattedMessage` will be