Test logging refactoring#1638
Merged
Merged
Conversation
Remove reflection-based method name lookup from test log messages and scopes by using caller member name helpers. Switch test logger factories from Serilog sinks to MartinCostello.Logging.XUnit and update test package references accordingly. Replace Serilog test logging with MartinCostello logger.
sipsorcery
approved these changes
May 26, 2026
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
This updates test logging to remove reflection-based method name lookup and replaces the Serilog-based xUnit logging setup with
MartinCostello.Logging.XUnit.Part of #1434
Why
Using
[CallerMemberName]is a better fit for test log messages and scopes thanSystem.Reflection.MethodBase.GetCurrentMethod()because the compiler supplies the caller name directly. That avoids reflection overhead, removes nullable/reflection-specific handling, and keeps the code simpler while still producing the same method names in test output.MartinCostello.Logging.XUnitis also a lighter-weight option for test logging. It plugs directly intoMicrosoft.Extensions.LoggingandITestOutputHelper, so the tests no longer need a full Serilog logger configuration plus xUnit and console sinks just to write test output. This reduces test-only dependencies and keeps logging setup focused on the xUnit test scenario.Changes
MartinCostello.Logging.XUnit.