Skip to content

ILogger.LogError(Exception, string) results in incorrect exception message in AppInsights #1325

@richardszalay

Description

@richardszalay
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.9.1" />

Steps to reproduce:

  1. Setup a basic ASP.NET Core application
  2. Configure AI using services.AddLogging(c => c.AddApplicationInsights())
  3. Throw an Exception with the message "Actual exception message"
  4. Catch the exception and log it to an injected ILogger using logger.LogError(ex, "Contextual message")
  5. Review the exception in AI

Expected:

Both "Contextual message" and "Actual exception message" are presented in the exception object in AI

Actual:

Only "Context message" is included. The actual exception message is lost.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions