Problem
Brighter routes all logging through a process-wide mutable static, ApplicationLogging.LoggerFactory. The dependency-injection extensions copy the container's ILoggerFactory into this static when building the CommandProcessor and Dispatcher.
Because it is a single static, it is shared between two or more Brighter instances running in the same process — a common situation in parallel test suites (each test class spins up its own ServiceProvider).
This leads to two failures:
-
Wrong logger from the wrong service provider. With two or more service providers, whichever Brighter initializes last overwrites the static. Code belonging to one instance then logs through the ILoggerFactory owned by a different service provider.
-
Disposal breaks other running instances. When a ServiceProvider is disposed it disposes its ILoggerFactory. The static still holds a reference to that now-disposed factory, so other still-running Brighter instances can throw ObjectDisposedException (or silently log nowhere) the next time they log.
The net effect is that two or more Brighters cannot run cleanly side by side in the same process.
Expected
Logging should be instance-scoped: each Brighter instance logs through the ILoggerFactory of the service provider that created it, and disposing one instance must not affect another.
Problem
Brighter routes all logging through a process-wide mutable static,
ApplicationLogging.LoggerFactory. The dependency-injection extensions copy the container'sILoggerFactoryinto this static when building theCommandProcessorandDispatcher.Because it is a single static, it is shared between two or more Brighter instances running in the same process — a common situation in parallel test suites (each test class spins up its own
ServiceProvider).This leads to two failures:
Wrong logger from the wrong service provider. With two or more service providers, whichever Brighter initializes last overwrites the static. Code belonging to one instance then logs through the
ILoggerFactoryowned by a different service provider.Disposal breaks other running instances. When a
ServiceProvideris disposed it disposes itsILoggerFactory. The static still holds a reference to that now-disposed factory, so other still-running Brighter instances can throwObjectDisposedException(or silently log nowhere) the next time they log.The net effect is that two or more Brighters cannot run cleanly side by side in the same process.
Expected
Logging should be instance-scoped: each Brighter instance logs through the
ILoggerFactoryof the service provider that created it, and disposing one instance must not affect another.