[API Proposal]: Expose NullExternalScopeProvider and NullScope #108993
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-Extensions-Logging
Milestone
Background and motivation
When writing a custom logging provider, it's not uncommon to want to provide a default logging scope backed by NullExternalScopeProvider/NullScope. This provides a good default for log providers or situations that either don't require scope support or where a sane default is required and can be replaced later (e.g. by the logger provider implementing
ISupportExternalScope
).API Proposal
NullExternalScopeProvider and NullScope should change their visibility from
internal
topublic
.Because these types are specifically designed as no-op replacements, no additional changes or considerations are required.
API Usage
This example assumes that
NullExternalScopeProvider.Instance
is passed in the logger provider's CreateScope instance. It features support for later updating the scope provider should the logger provider implementISupportExternalScope
Alternative Designs
Currently, consumers of M.E.L that intend to write their own logger provider are required to implement their own no-op scope and scope provider types, should they wish for this functionality.
Risks
No expected risks. These no-op scope and scope provider types are agnostic to the ultimate destination of the logger.
The text was updated successfully, but these errors were encountered: