Logs customization doc: filtering (#3034)
This commit is contained in:
parent
1c35335fd5
commit
4d6c05cb6b
|
|
@ -34,16 +34,25 @@ TODO
|
|||
|
||||
## Filtering LogLevels
|
||||
|
||||
TODO
|
||||
[`ILogger`](https://docs.microsoft.com/dotnet/core/extensions/logging)
|
||||
implementations have a built-in mechanism to apply [log
|
||||
filtering](https://docs.microsoft.com/dotnet/core/extensions/logging?tabs=command-line#how-filtering-rules-are-applied).
|
||||
This filtering lets you control the logs that are sent to each registered
|
||||
provider, including the `OpenTelemetryLoggerProvider`. "OpenTelemetry" is the
|
||||
[alias](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.provideraliasattribute)
|
||||
for `OpenTelemetryLoggerProvider`, that may be used in configuring filtering
|
||||
rules.
|
||||
|
||||
### via appsettings.json
|
||||
The example below defines "Error" as the default `LogLevel`
|
||||
and also defines "Warning" as the minimum `LogLevel` for a user defined category.
|
||||
|
||||
TODO
|
||||
|
||||
### via code
|
||||
|
||||
TODO
|
||||
```csharp
|
||||
ILoggingBuilder.AddFilter<OpenTelemetryLoggerProvider>("*", LogLevel.Error);
|
||||
ILoggingBuilder.AddFilter<OpenTelemetryLoggerProvider>("category name", LogLevel.Warning);
|
||||
```
|
||||
|
||||
## Learn more
|
||||
|
||||
* TODO
|
||||
* See also the official guide for
|
||||
[Logging in .NET](https://docs.microsoft.com/dotnet/core/extensions/logging).
|
||||
* [`LogLevel`](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.loglevel)
|
||||
|
|
|
|||
Loading…
Reference in New Issue