Skip to content

Commit

Permalink
Merge branch 'main' into alanwest/view-identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Apr 12, 2022
2 parents a948465 + 4cabb23 commit d5b5612
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/logs/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void Main()
{
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(
serviceName: "MyService",
serviceVersion: "1.0.0"));
Expand All @@ -41,5 +42,12 @@ public static void Main()
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");
}
}
}
10 changes: 9 additions & 1 deletion docs/logs/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d5b5612

Please sign in to comment.