Log customization doc: IncludeScopes (#3155)
This commit is contained in:
parent
9da4ff798a
commit
4cabb23f09
|
@ -29,6 +29,7 @@ public class Program
|
|||
{
|
||||
builder.AddOpenTelemetry(options =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(
|
||||
serviceName: "MyService",
|
||||
serviceVersion: "1.0.0"));
|
||||
|
@ -41,5 +42,12 @@ public class Program
|
|||
logger.LogInformation("Hello Information");
|
||||
logger.LogWarning("Hello Warning");
|
||||
logger.LogError("Hello Error");
|
||||
|
||||
// log with scopes
|
||||
using (logger.BeginScope("operation"))
|
||||
using (logger.BeginScope("hardware"))
|
||||
{
|
||||
logger.LogError("{name} is broken.", "refrigerator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,15 @@ TODO
|
|||
|
||||
### IncludeScopes
|
||||
|
||||
TODO
|
||||
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.
|
||||
|
||||
`IncludeScopes` is off by default. Setting this to `true` will include all
|
||||
scopes with the exported `LogRecord`. Consult the individual `Exporter`
|
||||
docs to learn more about how scopes will be processed.
|
||||
|
||||
See [Program.cs](Program.cs) for an example.
|
||||
|
||||
### IncludeFormattedMessage
|
||||
|
||||
|
|
Loading…
Reference in New Issue