C
C#11mo ago
nicke

AspNet.Core OpenTelemetry AzureMonitorLogExporter doesn't include ILogger name in AppInsight traces.

ILogger log messages get written to app insights but there is some info missing compared to writing to for example file or console. Console: InternalApi.DashboardController: Information: This is a info App insights: Does not contain any additional infromation except the LogLevel and the message. Can I somehow add more information to the traces or do i need to use Microsoft.ApplicationInsights.AspNetCore if i want that?
10 Replies
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
nicke
nickeOP11mo ago
really simple
builder.Logging.AddOpenTelemetry(x =>
{
x.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService("Frends-Management"));
x.IncludeFormattedMessage = true;

x.AddAzureMonitorLogExporter(options =>
{
options.ConnectionString = settings.ApplicationInsights.ConnectionString;
// Do not sample logs
options.SamplingRatio = 1F;
});
});
builder.Logging.AddOpenTelemetry(x =>
{
x.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService("Frends-Management"));
x.IncludeFormattedMessage = true;

x.AddAzureMonitorLogExporter(options =>
{
options.ConnectionString = settings.ApplicationInsights.ConnectionString;
// Do not sample logs
options.SamplingRatio = 1F;
});
});
And looks like this under traces when i use _logger.LogWarning... where the ILogger is injected from the constructor.
No description
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
nicke
nickeOP11mo ago
Yeah i've debugged that part of the code and the generated telemetryItems only contain the message and the log level But i'll probably just use the classic ApplicationInsights library as there it seems to work oob
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
nicke
nickeOP11mo ago
The customDimensions are populated from the actual log message when using composite formatting Just not stuff like line number, Logger name, file name etc
nicke
nickeOP11mo ago
Add, modify, and filter Azure Monitor OpenTelemetry for .NET, Java,...
This article provides guidance on how to add, modify, and filter OpenTelemetry for applications using Azure Monitor.
nicke
nickeOP11mo ago
Okey, that seems to only work for traces and metrics
nicke
nickeOP11mo ago
Same trace using the Microsoft.ApplicationInsights.AspNetCore with AddApplicationInsightsTelemetry()
No description
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server