Skip to content

Use LoggerMessage.Define overloads that disable the IsEnabled check #31332

Closed
@gfoidl

Description

@gfoidl

Depends on dotnet/runtime#45290

There are some places that benefit from this change.

Everywhere logger.IsEnabled is checked, can profit by removing the double-check.

Then there are some places where "heavier objects" need to be created, even if logging is disabled for that level.
(Can use this regex search).

Just from the first results-page (didn't check all / exhaustive) e.g.:

var formattedArguments = GetFormattedArguments(arguments);
_viewComponentExecuting(logger, context.ViewComponentDescriptor.DisplayName, formattedArguments, null);

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions