最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - The ILogger category name is not available in Application Insights when using Azure.Monitor.OpenTelemetry.AspNetCore in ASP

programmeradmin3浏览0评论

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:

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:

Share Improve this question edited Feb 16 at 13:23 marc_s 755k184 gold badges1.4k silver badges1.5k bronze badges asked Feb 16 at 11:32 ShuzhengShuzheng 14k29 gold badges116 silver badges227 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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 the CategoryName field was omitted, which was inconsistent with expected ILogger behavior, and with Application Insights classic behavior.
    (#44754)

https://github/Azure/azure-sdk-for-net/blob/cd4482ea1ef034f9c875e8c85bcff6704677dc08/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/CHANGELOG.md?plain=1#L32

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论