BrighterCommand / BrighterCommand/Brighter
Static ApplicationLogging.LoggerFactory is shared across Brighter instances in a process
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 296
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## 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:
1. **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.
2. **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.
Contributor guide
Assessment
This issue has not been assessed yet.