Skip to content

Convert tests from deprecated ForContext/SerilogLoggingAdapter to WithContext#312

Merged
Aaronontheweb merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:feature/convert-tests-to-withcontext
Feb 10, 2026
Merged

Convert tests from deprecated ForContext/SerilogLoggingAdapter to WithContext#312
Aaronontheweb merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:feature/convert-tests-to-withcontext

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Summary

Converts all test files that were using the now-deprecated SerilogLoggingAdapter and ForContext() APIs to use the standard ILoggingAdapter with WithContext().

Changes

  • ForContextSpecs: Switched to IAsyncLifetime, uses Logging.GetLogger() with WithContext() instead of SerilogLoggingAdapter/ForContext(). Removed duplicate tests that tested the same behavior via both adapter paths.
  • SemanticLoggingSpecs: Uses Logging.GetLogger() instead of new SerilogLoggingAdapter(). Converted ForContext test to WithContext.
  • SerilogFormattingSpecs: Uses Logging.GetLogger() instead of new SerilogLoggingAdapter().
  • Bugfix4579Spec: Uses Context.GetLogger() and WithContext() in actor. Added logger-formatter to HOCON config.

Test plan

  • 775/775 tests pass on net8.0
  • Zero CS0618 obsolete warnings from test code
  • Build succeeds with 0 errors

…hContext

- ForContextSpecs: switch to IAsyncLifetime, use standard ILoggingAdapter
  with WithContext() instead of SerilogLoggingAdapter/ForContext()
- SemanticLoggingSpecs: use Logging.GetLogger() instead of new
  SerilogLoggingAdapter(), convert ForContext test to WithContext
- SerilogFormattingSpecs: use Logging.GetLogger() instead of new
  SerilogLoggingAdapter()
- Bugfix4579Spec: use Context.GetLogger() and WithContext() in actor,
  add logger-formatter to HOCON config

All 775 tests pass on net8.0.
Replace the fire-once + destructive-dequeue pattern with AwaitAssertAsync
and non-destructive ToArray() snapshots. The old pattern sent the log
message once outside the retry loop and used TryDequeue which permanently
discarded non-matching events. On net471, the slower ThreadPool meant
the SerilogLogger actor often hadn't processed the message within the
3-second AwaitCondition timeout.

The new pattern re-sends the log message inside each AwaitAssertAsync
retry and uses ToArray().FirstOrDefault() for non-destructive matching,
consistent with all other test classes in this project.

All 775 tests pass on both net8.0 and net471.
Beef up README with comprehensive documentation: how the library works,
setup options (Akka.Hosting + HOCON), semantic logging, WithContext(),
and a full section on Serilog configuration compatibility.

Update release notes to clarify these are deprecations (not breaking
changes) and add explicit "What's NOT Changing" section covering global
enrichers, properties, sinks, output templates, LogContext, and level
switches.
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) February 10, 2026 18:19
@Aaronontheweb Aaronontheweb merged commit 695099a 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