Skip to content

Commit 4631857

Browse files
committed
suggestions
1 parent 2abcd4e commit 4631857

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

docs/core/enrichment/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To use log enrichment in your application, you need to:
3232

3333
Here's a simple example showing how to set up log enrichment with process information:
3434

35-
:::code language="csharp" source="snippets/enrichment/Program.cs" highlight="13,14":::
35+
:::code language="csharp" source="snippets/enrichment/Program.cs" highlight="8,9":::
3636

3737
This configuration:
3838

docs/core/enrichment/process-log-enricher.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dotnet package add Microsoft.Extensions.Telemetry
3939

4040
To use the process log enricher, first you enable enrichment. Then you can add the <xref:Microsoft.Extensions.DependencyInjection.ProcessEnricherServiceCollectionExtensions.AddProcessLogEnricher*> with default properties, as shown in the following code:
4141

42-
:::code language="csharp" source="snippets/enrichment/Program.cs" highlight="13,14":::
42+
:::code language="csharp" source="snippets/enrichment/Program.cs" highlight="8,9":::
4343

4444
Given this code sample, the output should be similar to the following JSON:
4545

docs/core/enrichment/snippets/enrichment/Program.cs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,21 @@
33
using Microsoft.Extensions.Hosting;
44
using Microsoft.Extensions.Logging;
55

6-
namespace Enrichment
6+
var builder = Host.CreateApplicationBuilder(args);
7+
8+
builder.Logging.EnableEnrichment();
9+
builder.Services.AddProcessLogEnricher();
10+
11+
builder.Logging.AddJsonConsole(op =>
712
{
8-
internal class Program
13+
op.JsonWriterOptions = new JsonWriterOptions
914
{
10-
public static async Task Main()
11-
{
12-
var builder = Host.CreateApplicationBuilder();
13-
builder.Logging.EnableEnrichment();
14-
builder.Services.AddProcessLogEnricher();
15-
builder.Logging.AddJsonConsole(op =>
16-
{
17-
op.JsonWriterOptions = new JsonWriterOptions
18-
{
19-
Indented = true
20-
};
21-
});
22-
var hostBuilder = builder.Build();
23-
var logger =
24-
hostBuilder.Services.GetRequiredService<ILoggerFactory>().CreateLogger<Program>();
25-
26-
logger.LogInformation("This is a sample log message");
15+
Indented = true
16+
};
17+
});
2718

28-
await hostBuilder.RunAsync();
19+
var host = builder.Build();
20+
var logger = host.Services.GetRequiredService<ILogger<Program>>();
2921

30-
}
31-
}
32-
}
22+
logger.LogInformation("This is a sample log message");
23+
await host.RunAsync();

0 commit comments

Comments
 (0)