Skip to content

Change ILoggerFactory internal lifetime to scoped #14698

@ajcvickers

Description

@ajcvickers

This has the following advantages:

  • It eliminates internal service provider explosion when calling UseLoggerFactory with a new instance each time. This is currently a significant pit of failure that has consumed many victims.
  • This also means that the testing pattern of multiple external service provides (e.g. one per test) does not cause the internal cache to explode.
  • It allows a simple implementation for simple logging APIs, since each context instance can naturally have its own logger if desired.

The disadvantages are:

  • Internal singleton services cannot depend directly on a logger from D.I. This means either:
    • Making the service scoped
    • Flowing in the logger from a scoped service, which in turn may require breaking changes to add new logging

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions