Inconsistent log level for ActionMethodExecuting
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
The ActionMethodExecuting log is marked as "Informational", yet is only enabled when the DiagnosticListener is enabled or logging is set to "Trace"
In `InvokeActionMethodAsync`, the instrumented path is taken only if the DiagnosticListener is enabled or logging is set to "Trace": https://github.com/dotnet/aspnetcore/blob/8df64902404e31c336ea3386fffe831e99072471/src/Mvc/Mvc.Core/src/Infrastructure/ControllerActionInvoker.cs#L385
Yet, in `ActionMethodExecuting`, the `_actionMethodExecuting` log is called when the log level is set to informational:
https://github.com/dotnet/aspnetcore/blob/8df64902404e31c336ea3386fffe831e99072471/src/Mvc/Mvc.Core/src/MvcCoreLoggerExtensions.cs#L892
This causes additional logs to be written when the DiagnosticListener is enabled, even though the log level hasn't been changed.
### To Reproduce
- Run an aspnetcore app with the DiagnosticListener enabled and logs set to info: the ActionMethodExecuting logs are enabled
- Run the same app without the DiagnosticListener: the ActionMethodExecuting logs are disabled
Contributor guide
Assessment
This issue has not been assessed yet.