Skip to content

Add WithContext() support and deprecate Serilog-specific ForContext()#310

Merged
Aaronontheweb merged 4 commits into
akkadotnet:devfrom
Aaronontheweb:feature/withcontext-support
Feb 10, 2026
Merged

Add WithContext() support and deprecate Serilog-specific ForContext()#310
Aaronontheweb merged 4 commits into
akkadotnet:devfrom
Aaronontheweb:feature/withcontext-support

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Summary

  • SerilogLogger.GetLogger() now calls TryGetProperties() to extract context properties set via the core WithContext() API and converts them to Serilog PropertyEnrichers
  • Deprecated SerilogLoggingAdapter class and ForContext() extension method in favor of the core ILoggingAdapter.WithContext() method
  • Added WithContextSpecs integration tests validating context enrichment flows through to Serilog log events

Dependencies

Depends on akkadotnet/akka.net#8042 (logging context scopes). CI will fail until the new Akka.NET packages are published.

Test plan

  • WithContext_SingleProperty_AppearsInSerilogProperties - validated locally
  • WithContext_MultipleProperties_AllAppear - validated locally
  • WithContext_CombinedWithSemanticTemplate_BothAppear - validated locally
  • WithContext_DoesNotPolluteUnrelatedLogs - validated locally
  • Full regression (778/778 pass) - validated locally against 1.5.60-beta packages

SerilogLogger now calls TryGetProperties() to extract context properties
set via the core WithContext() API and converts them to Serilog
PropertyEnrichers. This enables structured context enrichment through
the standard Akka.NET logging API.

Deprecated SerilogLoggingAdapter and ForContext() extension in favor of
the core ILoggingAdapter.WithContext() method.

Depends on akkadotnet/akka.net#8042
Update Akka.NET dependency to 1.5.60 which includes the WithContext() logging context enrichment feature.
@Aaronontheweb Aaronontheweb marked this pull request as ready for review February 10, 2026 02:14
- Update README to recommend WithContext() over ForContext()/SerilogLoggingAdapter
- Update semantic logging section to show standard ILoggingAdapter usage
- Add deprecation notice for SerilogLoggingAdapter and ForContext()
- Add migration guide from ForContext() to WithContext()
- Update RELEASE_NOTES.md with 1.5.60 entry
- Bump VersionPrefix to 1.5.60 and update PackageReleaseNotes
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) February 10, 2026 04:51
@Aaronontheweb Aaronontheweb merged commit 81ae8c2 into akkadotnet:dev Feb 10, 2026
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.

1 participant