Making sure the basic logging infrastructure is always wired up#7659
Conversation
|
https://github.com/Particular/NServiceBus/blob/5787dbd2ecbe2e361c21e618af5b55ef024c9619/src/NServiceBus.Core.Tests/Config/When_starting_an_endpoint_with_already_used_configuration.cs now fails due to transport being reused and not that the endpoint config is being reused. Don't we already have a test for this? |
…nd simplify `ServiceCollection` usage
This reverts commit fa5ddb5.
…with `ContextAppenderLoggerProvider`
|
|
||
| public static class Scenario | ||
| { | ||
| public static Func<ScenarioContext, ILoggerFactory> GetLoggerFactory { get; set; } = _ => new ContextAppenderNServiceBusLoggerFactory(); |
There was a problem hiding this comment.
We are not giving any backward compatibility guarantees for acceptance testing, so this is OK to remove
https://github.com/search?q=org%3AParticular%20GetLoggerFactory&type=code
| TestExecutionContext.CurrentContext.AddRunDescriptor(runDescriptor); | ||
| ScenarioContext.Current = scenarioContext; | ||
|
|
||
| LogManager.UseFactory(Scenario.GetLoggerFactory(scenarioContext)); |
There was a problem hiding this comment.
This is no longer required because the Core logging bridge takes care of intercepting things properly
| get; | ||
| get | ||
| { | ||
| using var _ = gate.EnterScope(); |
There was a problem hiding this comment.
Making sure the access to Inner is gated too
|
FYI @bording |
Follow through on #7658
This pull request introduces a significant refactor of the logging infrastructure in the acceptance testing and core hosting code. The main changes are a migration from custom logger factories to Microsoft.Extensions.Logging providers, removal of legacy logging classes, and updates to test and endpoint setup logic to align with the new logging approach. Additionally, some test code has been modernized for clarity and conciseness.
Logging infrastructure refactor
ContextAppenderMicrosoftLoggerFactorywith a newContextAppenderLoggerProviderimplementingILoggerProviderandISupportExternalScope, and updated registration logic to use Microsoft.Extensions.Logging APIs. (src/NServiceBus.AcceptanceTesting/ContextAppenderLoggerProvider.cs) [1] [2] [3]ContextAppenderNServiceBusLoggerandContextAppenderNServiceBusLoggerFactory, as well as the associated factory registration inScenario. (src/NServiceBus.AcceptanceTesting/ContextAppenderNServiceBusLogger.cs,src/NServiceBus.AcceptanceTesting/ContextAppenderNServiceBusLoggerFactory.cs,src/NServiceBus.AcceptanceTesting/Scenario.cs) [1] [2] [3]Core hosting and endpoint setup
EndpointCreator.Configure()to register logging as a global service concern using Microsoft.Extensions.Logging, and modernized service registration patterns. (src/NServiceBus.Core/EndpointCreator.cs) [1] [2] [3]EndpointPreparationto resolve and register the Microsoft logger factory as the slot factory for logging, replacing the previous bridge logic. (src/NServiceBus.Core/Hosting/EndpointPreparation.cs) [1] [2]Test code improvements
src/NServiceBus.Core.Tests/Config/When_configuring_transport_twice.cs,src/NServiceBus.Core.Tests/Config/When_starting_an_endpoint_with_already_used_configuration.cs,src/NServiceBus.Core.Tests/Config/When_starting_endpoint_without_configuring_serializer.cs,src/NServiceBus.Core.Tests/Config/When_using_initialization.cs) [1] [2] [3] [4] [5] [6] [7] [8]Miscellaneous
KeyedServiceCollectionAdapterby adding a scoped lock. (src/NServiceBus.Core/Hosting/KeyedServices/KeyedServiceCollectionAdapter.cs)EndpointLoggingScopeTests, as they are no longer relevant to the new logging infrastructure. (src/NServiceBus.Core.Tests/Logging/EndpointLoggingScopeTests.cs)