@@ -32,14 +32,15 @@ internal static class MvcCoreLoggerExtensions
32
32
private static readonly double TimestampToTicks = TimeSpan . TicksPerSecond / ( double ) Stopwatch . Frequency ;
33
33
34
34
private static readonly Action < ILogger , string , string , Exception > _actionExecuting ;
35
+ private static readonly Action < ILogger , string , MethodInfo , string , string , Exception > _controllerActionExecuting ;
35
36
private static readonly Action < ILogger , string , double , Exception > _actionExecuted ;
36
37
37
38
private static readonly Action < ILogger , string [ ] , Exception > _challengeResultExecuting ;
38
39
39
40
private static readonly Action < ILogger , string , Exception > _contentResultExecuting ;
40
41
41
42
private static readonly Action < ILogger , string , ModelValidationState , Exception > _actionMethodExecuting ;
42
- private static readonly Action < ILogger , string , string [ ] , ModelValidationState , Exception > _actionMethodExecutingWithArguments ;
43
+ private static readonly Action < ILogger , string , string [ ] , Exception > _actionMethodExecutingWithArguments ;
43
44
private static readonly Action < ILogger , string , string , double , Exception > _actionMethodExecuted ;
44
45
45
46
private static readonly Action < ILogger , string , string [ ] , Exception > _logFilterExecutionPlan ;
@@ -153,6 +154,11 @@ static MvcCoreLoggerExtensions()
153
154
1 ,
154
155
"Route matched with {RouteData}. Executing action {ActionName}" ) ;
155
156
157
+ _controllerActionExecuting = LoggerMessage . Define < string , MethodInfo , string , string > (
158
+ LogLevel . Information ,
159
+ 3 ,
160
+ "Route matched with {RouteData}. Executing controller action with signature {MethodInfo} on controller {Controller} ({AssemblyName})." ) ;
161
+
156
162
_actionExecuted = LoggerMessage . Define < string , double > (
157
163
LogLevel . Information ,
158
164
2 ,
@@ -173,10 +179,10 @@ static MvcCoreLoggerExtensions()
173
179
1 ,
174
180
"Executing action method {ActionName} - Validation state: {ValidationState}" ) ;
175
181
176
- _actionMethodExecutingWithArguments = LoggerMessage . Define < string , string [ ] , ModelValidationState > (
177
- LogLevel . Information ,
178
- 1 ,
179
- "Executing action method {ActionName} with arguments ({Arguments}) - Validation state: {ValidationState} " ) ;
182
+ _actionMethodExecutingWithArguments = LoggerMessage . Define < string , string [ ] > (
183
+ LogLevel . Trace ,
184
+ 3 ,
185
+ "Executing action method {ActionName} with arguments ({Arguments})" ) ;
180
186
181
187
_actionMethodExecuted = LoggerMessage . Define < string , string , double > (
182
188
LogLevel . Information ,
@@ -683,7 +689,22 @@ public static void ExecutingAction(this ILogger logger, ActionDescriptor action)
683
689
}
684
690
}
685
691
686
- _actionExecuting ( logger , stringBuilder . ToString ( ) , action . DisplayName , null ) ;
692
+ if ( action is ControllerActionDescriptor controllerActionDescriptor )
693
+ {
694
+ var controllerType = controllerActionDescriptor . ControllerTypeInfo . AsType ( ) ;
695
+ var controllerName = TypeNameHelper . GetTypeDisplayName ( controllerType ) ;
696
+ _controllerActionExecuting (
697
+ logger ,
698
+ stringBuilder . ToString ( ) ,
699
+ controllerActionDescriptor . MethodInfo ,
700
+ controllerName ,
701
+ controllerType . Assembly . GetName ( ) . Name ,
702
+ null ) ;
703
+ }
704
+ else
705
+ {
706
+ _actionExecuting ( logger , stringBuilder . ToString ( ) , action . DisplayName , null ) ;
707
+ }
687
708
}
688
709
}
689
710
@@ -814,21 +835,17 @@ public static void ActionMethodExecuting(this ILogger logger, ControllerContext
814
835
var actionName = context . ActionDescriptor . DisplayName ;
815
836
816
837
var validationState = context . ModelState . ValidationState ;
838
+ _actionMethodExecuting ( logger , actionName , validationState , null ) ;
817
839
818
- string [ ] convertedArguments ;
819
- if ( arguments == null )
820
- {
821
- _actionMethodExecuting ( logger , actionName , validationState , null ) ;
822
- }
823
- else
840
+ if ( arguments != null && logger . IsEnabled ( LogLevel . Trace ) )
824
841
{
825
- convertedArguments = new string [ arguments . Length ] ;
842
+ var convertedArguments = new string [ arguments . Length ] ;
826
843
for ( var i = 0 ; i < arguments . Length ; i ++ )
827
844
{
828
845
convertedArguments [ i ] = Convert . ToString ( arguments [ i ] ) ;
829
846
}
830
847
831
- _actionMethodExecutingWithArguments ( logger , actionName , convertedArguments , validationState , null ) ;
848
+ _actionMethodExecutingWithArguments ( logger , actionName , convertedArguments , null ) ;
832
849
}
833
850
}
834
851
}
0 commit comments