Skip to content

Commit fbdfe45

Browse files
committed
fix
1 parent fac8d45 commit fbdfe45

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,40 @@ Here's a complete example showing how to set up the service log enricher:
165165

166166
**Program.cs:**
167167

168+
### [.NET 10+](#tab/net10-plus-config)
169+
170+
```csharp
171+
using System.Text.Json;
172+
using Microsoft.Extensions.DependencyInjection;
173+
using Microsoft.Extensions.Hosting;
174+
using Microsoft.Extensions.Logging;
175+
176+
var builder = Host.CreateApplicationBuilder(args);
177+
builder.UseApplicationMetadata();
178+
builder.Logging.EnableEnrichment();
179+
builder.Logging.AddJsonConsole(op =>
180+
{
181+
op.JsonWriterOptions = new JsonWriterOptions
182+
{
183+
Indented = true
184+
};
185+
});
186+
builder.Services.AddApplicationLogEnricher(builder.Configuration.GetSection("ApplicationLogEnricherOptions"));
187+
188+
var host = builder.Build();
189+
var logger = host.Services.GetRequiredService<ILogger<Program>>();
190+
191+
logger.LogInformation("This is a sample log message");
192+
193+
await host.RunAsync();
194+
```
195+
196+
### [.NET 9 and earlier](#tab/net9-earlier-config)
197+
168198
:::code language="csharp" source="snippets/servicelogenricher/Program.cs" :::
169199

200+
---
201+
170202
### Enriched log output
171203

172204
With the service log enricher configured, your log output will include service-specific dimensions:

0 commit comments

Comments
 (0)