Skip to content

ObjectResultExecutor could output a clearer log w.r.t the concrete type of ObjectResult #21393

Closed
@andrewjsaid

Description

@andrewjsaid

Is your feature request related to a problem? Please describe.

ObjectResultExecutor gives potentially misleading log. Specifically "ObjectResultExecuting" is define in MvcCoreLoggerExtensions as follows:
Executing ObjectResult, writing value of type '{Type}'.

The misleading part is when a controller returns, for example, a NotFoundObjectResult(string) or an OkObjectResult(string). The logs look like this in either case:
[Information] Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor: Executing ObjectResult, writing value of type 'System.String'.

Describe the solution you'd like

My suggestion is to output the declared runtime/real/concrete type of ObjectResult along the lines of
Executing {ConcreteObjectResultType}, writing value of type '{Type}'.

The above message is more useful because

  1. It provides more detail as to what happened.
  2. It does not leak implementation details of NotFoundObjectResult.

Additional context

Of course, there are other ways to discover the same information (such as the Status Code) so this issue is not critical. Another point against this issue is that the ControllerActionInvoker does specify the runtime type of ActionResult.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onegood first issueGood for newcomers.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions