Convert tests from deprecated ForContext/SerilogLoggingAdapter to WithContext#312
Merged
Aaronontheweb merged 3 commits intoFeb 10, 2026
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts all test files that were using the now-deprecated
SerilogLoggingAdapterandForContext()APIs to use the standardILoggingAdapterwithWithContext().Changes
IAsyncLifetime, usesLogging.GetLogger()withWithContext()instead ofSerilogLoggingAdapter/ForContext(). Removed duplicate tests that tested the same behavior via both adapter paths.Logging.GetLogger()instead ofnew SerilogLoggingAdapter(). ConvertedForContexttest toWithContext.Logging.GetLogger()instead ofnew SerilogLoggingAdapter().Context.GetLogger()andWithContext()in actor. Addedlogger-formatterto HOCON config.Test plan