Skip to content

Serialize complex objects in exception data logging#25267

Merged
EngincanV merged 5 commits into
devfrom
fix/exception-data-logging-format
Apr 15, 2026
Merged

Serialize complex objects in exception data logging#25267
EngincanV merged 5 commits into
devfrom
fix/exception-data-logging-format

Conversation

@maliming

Copy link
Copy Markdown
Member

When exception.Data contains complex objects (e.g. List<Dictionary<string, object>>), LogData outputs the type name instead of actual content. This uses JsonSerializer for non-primitive types to produce meaningful JSON output in logs, with a fallback to ToString() if serialization fails.

Use JsonSerializer for non-primitive types in AbpLoggerExtensions.LogData
to output meaningful JSON instead of type names like List`1[Dictionary`2[...]]
Copilot AI review requested due to automatic review settings April 15, 2026 06:32
@maliming maliming added this to the 10.4-preview milestone Apr 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ABP’s exception data logging to output meaningful content when Exception.Data contains complex objects by JSON-serializing non-primitive values, and adds unit tests to validate the formatting behavior.

Changes:

  • Serialize non-primitive Exception.Data values to JSON in AbpLoggerExtensions.LogException logging output, with fallback to ToString() on serialization failure.
  • Add unit tests covering formatting of string/primitive/enum/Guid/DateTime/null and complex object/list values in exception data.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs Adds FormatDataValue and uses JsonSerializer.Serialize to log complex Exception.Data values as JSON.
framework/test/Volo.Abp.Core.Tests/Microsoft/Extensions/Logging/AbpLoggerExtensions_Tests.cs Introduces tests validating the new exception data formatting behavior for multiple value types.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

@maliming maliming requested a review from EngincanV April 15, 2026 07:58
@EngincanV EngincanV merged commit b42b4a6 into dev Apr 15, 2026
3 checks passed
@EngincanV EngincanV deleted the fix/exception-data-logging-format branch April 15, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants