I'm using the Azure.Monitor.OpenTelemetry.AspNetCore
OTEL package to emit telemtry to Application Insights for an ASP.NET Core application (.NET 8).
Within Application Insights, I don't see the "Category" field that I would normally see for e.g. function apps. This field captures the category in ILogger<Category>
, so I find it extremely useful for identifying the code that emitted the log.
How can I make the package also include the logging category?
Packages:
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
Code:
logger.LogInformation("Fetched all users");
Application Insights:
This bug was fixed in Azure.Monitor.OpenTelemetry.Exporter
v1.4.0-beta.1.
This is included in Azure.Monitor.OpenTelemetry.AspNetCore
v1.3.0-beta.2, so upgrade the package reference (from v1.2.0) to:
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.3.0-beta.2" />
1.4.0-beta.1 (2024-07-12)
Bugs Fixed
- Added the
LogRecord.CategoryName
field to log and exception telemetry. Previously theCategoryName
field was omitted, which was inconsistent with expectedILogger
behavior, and with Application Insights classic behavior.
(#44754)