I want to see my ASP.NET Core application's logs in Application Insights.
I'm using the following packages:
Azure.Monitor.OpenTelemetry.AspNetCoreSerilog.AspNetCoreSerilog.Sinks.OpenTelemetry
This is the current setup:
builder.Services.AddOpenTelemetry()
.UseAzureMonitor()
.ConfigureResource(x =>
{
x.AddAttributes(new Dictionary<string, object> { { "service.name", "my-service" } });
})
.WithTracing();
builder.Services.AddSerilog((services, lc) => lc
.ReadFrom.Configuration(builder.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console(builder.Environment.IsDevelopment()
? new RenderedCompactJsonFormatter()
: new CompactJsonFormatter())
.WriteTo.OpenTelemetry()
);
The connection string is passed via the environment variable APPLICATIONINSIGHTS_CONNECTION_STRING. I can see requests in the Application Insights dashboard, but no traces/logs. What's missing here?