[API Proposal]: Interpolated string overloads of ILogger extensions #111283
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-Extensions-Logging
Background and motivation
LoggerExtensions
provides a plethora of methods like:We strongly encourage developers to use structured logging, either by having their messages to such calls be literals, with arguments filled in from the supplied params, or by using the logger generator to have strongly-typed logging methods. However, ridiculous amounts of code continue to just do the simple thing of using interpolated strings, e.g.
and to do so in a way where the calls are not guarded by
IsEnabled
checks for theLogLevel
. That means that all of the expense associated with generating the messages are incurred even if it's then immediately thrown away.We can address that by adding interpolated string handler overloads, which can avoid the associated costs when the relevant log level isn't enabled.
API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: