Skip to content

feat: add semantic logging support for Akka.NET 1.5.56+#294

Merged
Arkatufus merged 11 commits into
akkadotnet:devfrom
Aaronontheweb:feature/semantic-logging-enhancements
Dec 3, 2025
Merged

feat: add semantic logging support for Akka.NET 1.5.56+#294
Arkatufus merged 11 commits into
akkadotnet:devfrom
Aaronontheweb:feature/semantic-logging-enhancements

Conversation

@Aaronontheweb
Copy link
Copy Markdown
Member

Summary

Adds semantic logging support to leverage Akka.NET's new semantic logging APIs introduced in version 1.5.56.

This enhancement enables Serilog to receive properly structured message templates and parameters instead of pre-formatted strings, enabling richer structured logging capabilities.

Changes

  • SerilogLogger.cs: Modified GetFormat() and GetArgs() methods to unwrap SerilogPayload and use semantic logging pattern
  • SemanticLoggingSpecs.cs: Added comprehensive test suite with 9 tests covering all semantic logging scenarios

Test Coverage

New test suite includes:

  • ✅ Named and positional template properties
  • ✅ Multiple properties handling
  • ✅ Destructuring operator (@) support
  • ✅ Stringification operator ($) support
  • ✅ Format specifiers (:N2) handling
  • ✅ ForContext integration
  • ✅ Akka metadata preservation
  • ✅ Empty properties handling

All 765 existing tests pass.

Backwards Compatibility

Fully backwards compatible through LogMessage type checking. Works with both older and newer Akka.NET versions.

Dependencies

Requires Akka.NET >= 1.5.56 (not yet released)

Notes

  • CI/CD will fail until Akka.NET 1.5.56 is published to NuGet
  • This PR is ready for review but should not be merged until the Akka.NET dependency is available

Enhances SerilogLogger to leverage Akka.NET's new semantic logging APIs
introduced in version 1.5.56. This change enables structured logging with
proper message template and parameter extraction.

Changes:
- Modified SerilogLogger.GetFormat() and GetArgs() to unwrap SerilogPayload
  and use semantic logging pattern (checks for LogMessage and extracts template)
- Serilog now receives proper message templates instead of formatted strings
- Added comprehensive test suite (SemanticLoggingSpecs.cs) with 9 tests covering:
  * Named and positional template properties
  * Multiple properties handling
  * Destructuring operator (@) support
  * Stringification operator ($) support
  * Format specifiers handling
  * ForContext integration
  * Akka metadata preservation

All existing tests pass (765 tests). Backwards compatible with earlier
Akka.NET versions through LogMessage type checking.

Depends on: Akka.NET >= 1.5.56
- Updated Akka.NET dependency from 1.5.25 to 1.5.56
- Commented out OutputType and StartupObject in test project to enable test discovery
- Added xunit.runner.visualstudio package for better IDE integration
- Required for semantic logging API support
@Arkatufus Arkatufus marked this pull request as ready for review December 3, 2025 17:59
@Arkatufus Arkatufus merged commit 49ed18b into akkadotnet:dev Dec 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants