From 027bf336da4ee6cfd3894f7feafe029396413bde Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 8 Dec 2018 13:00:16 +0530 Subject: [PATCH] Add event names for logs (#6818) (#4495) * Add event names for logs (#6818) --- .../MvcCoreLoggerExtensions.cs | 196 +++++++++--------- .../CorsLoggerExtensions.cs | 2 +- .../MvcJsonLoggerExtensions.cs | 4 +- .../LoggerExtensions.cs | 6 +- .../MvcRazorLoggerExtensions.cs | 37 ++-- .../PageLoggerExtensions.cs | 20 +- .../MvcTagHelpersLoggerExtensions.cs | 2 +- .../MvcViewFeaturesLoggerExtensions.cs | 32 +-- 8 files changed, 147 insertions(+), 152 deletions(-) diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreLoggerExtensions.cs index e731b3be50..51d5142bc1 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreLoggerExtensions.cs @@ -156,407 +156,407 @@ namespace Microsoft.AspNetCore.Mvc { _actionExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ActionExecuting"), "Route matched with {RouteData}. Executing action {ActionName}"); _actionExecuted = LoggerMessage.Define( LogLevel.Information, - 2, + new EventId(2, "ActionExecuted"), "Executed action {ActionName} in {ElapsedMilliseconds}ms"); _pageExecuting = LoggerMessage.Define( LogLevel.Information, - 3, + new EventId(3, "PageExecuting"), "Route matched with {RouteData}. Executing page {PageName}"); _pageExecuted = LoggerMessage.Define( LogLevel.Information, - 4, + new EventId(4, "PageExecuted"), "Executed page {PageName} in {ElapsedMilliseconds}ms"); _challengeResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ChallengeResultExecuting"), "Executing ChallengeResult with authentication schemes ({Schemes})."); _contentResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ContentResultExecuting"), "Executing ContentResult with HTTP Response ContentType of {ContentType}"); _actionMethodExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ActionMethodExecuting"), "Executing action method {ActionName} - Validation state: {ValidationState}"); _actionMethodExecutingWithArguments = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ActionMethodExecutingWithArguments"), "Executing action method {ActionName} with arguments ({Arguments}) - Validation state: {ValidationState}"); _actionMethodExecuted = LoggerMessage.Define( LogLevel.Information, - 2, + new EventId(2, "ActionMethodExecuted"), "Executed action method {ActionName}, returned result {ActionResult} in {ElapsedMilliseconds}ms."); _logFilterExecutionPlan = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, "FilterExecutionPlan"), "Execution plan of {FilterType} filters (in the following order): {Filters}"); _beforeExecutingMethodOnFilter = LoggerMessage.Define( LogLevel.Trace, - 2, + new EventId(2, "BeforeExecutingMethodOnFilter"), "{FilterType}: Before executing {Method} on filter {Filter}."); _afterExecutingMethodOnFilter = LoggerMessage.Define( LogLevel.Trace, - 3, + new EventId(3, "AfterExecutingMethodOnFilter"), "{FilterType}: After executing {Method} on filter {Filter}."); _beforeExecutingActionResult = LoggerMessage.Define( LogLevel.Trace, - 4, + new EventId(4, "BeforeExecutingActionResult"), "Before executing action result {ActionResult}."); _afterExecutingActionResult = LoggerMessage.Define( LogLevel.Trace, - 5, + new EventId(5, "AfterExecutingActionResult"), "After executing action result {ActionResult}."); _ambiguousActions = LoggerMessage.Define( LogLevel.Error, - 1, + new EventId(1, "AmbiguousActions"), "Request matched multiple actions resulting in ambiguity. Matching actions: {AmbiguousActions}"); _constraintMismatch = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, "ConstraintMismatch"), "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'"); _executingFileResult = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ExecutingFileResult"), "Executing {FileResultType}, sending file '{FileDownloadPath}' with download name '{FileDownloadName}' ..."); _executingFileResultWithNoFileName = LoggerMessage.Define( LogLevel.Information, - 2, + new EventId(2, "ExecutingFileResultWithNoFileName"), "Executing {FileResultType}, sending file with download name '{FileDownloadName}' ..."); _authorizationFailure = LoggerMessage.Define( LogLevel.Information, - 3, + new EventId(3, "AuthorizationFailure"), "Authorization failed for the request at filter '{AuthorizationFilter}'."); _resourceFilterShortCircuit = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, "ResourceFilterShortCircuit"), "Request was short circuited at resource filter '{ResourceFilter}'."); _resultFilterShortCircuit = LoggerMessage.Define( LogLevel.Debug, - 5, + new EventId(5, "ResultFilterShortCircuit"), "Request was short circuited at result filter '{ResultFilter}'."); _actionFilterShortCircuit = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "ActionFilterShortCircuit"), "Request was short circuited at action filter '{ActionFilter}'."); _exceptionFilterShortCircuit = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, "ExceptionFilterShortCircuit"), "Request was short circuited at exception filter '{ExceptionFilter}'."); _forbidResultExecuting = LoggerMessage.Define( LogLevel.Information, - eventId: 1, + new EventId(1, "ForbidResultExecuting"), formatString: $"Executing {nameof(ForbidResult)} with authentication schemes ({{Schemes}})."); _signInResultExecuting = LoggerMessage.Define( LogLevel.Information, - eventId: 1, + new EventId(1, "SignInResultExecuting"), formatString: $"Executing {nameof(SignInResult)} with authentication scheme ({{Scheme}}) and the following principal: {{Principal}}."); _signOutResultExecuting = LoggerMessage.Define( LogLevel.Information, - eventId: 1, + new EventId(1, "SignOutResultExecuting"), formatString: $"Executing {nameof(SignOutResult)} with authentication schemes ({{Schemes}})."); _httpStatusCodeResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "HttpStatusCodeResultExecuting"), "Executing HttpStatusCodeResult, setting HTTP status code {StatusCode}"); _localRedirectResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "LocalRedirectResultExecuting"), "Executing LocalRedirectResult, redirecting to {Destination}."); _noFormatter = LoggerMessage.Define( LogLevel.Warning, - 1, + new EventId(1, "NoFormatter"), "No output formatter was found for content type '{ContentType}' to write the response."); _objectResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "ObjectResultExecuting"), "Executing ObjectResult, writing value of type '{Type}'."); _formatterSelected = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, "FormatterSelected"), "Selected output formatter '{OutputFormatter}' and content type '{ContentType}' to write the response."); _skippedContentNegotiation = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "SkippedContentNegotiation"), "Skipped content negotiation as content type '{ContentType}' is explicitly set for the response."); _noAcceptForNegotiation = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, "NoAcceptForNegotiation"), "No information found on request to perform content negotiation."); _noFormatterFromNegotiation = LoggerMessage.Define>( LogLevel.Debug, - 5, + new EventId(5, "NoFormatterFromNegotiation"), "Could not find an output formatter based on content negotiation. Accepted types were ({AcceptTypes})"); _inputFormatterSelected = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, "InputFormatterSelected"), "Selected input formatter '{InputFormatter}' for content type '{ContentType}'."); _inputFormatterRejected = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, "InputFormatterRejected"), "Rejected input formatter '{InputFormatter}' for content type '{ContentType}'."); _noInputFormatterSelected = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "NoInputFormatterSelected"), "No input formatter was found to support the content type '{ContentType}' for use with the [FromBody] attribute."); _removeFromBodyAttribute = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, "RemoveFromBodyAttribute"), "To use model binding, remove the [FromBody] attribute from the property or parameter named '{ModelName}' with model type '{ModelType}'."); _redirectResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "RedirectResultExecuting"), "Executing RedirectResult, redirecting to {Destination}."); _redirectToActionResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "RedirectToActionResultExecuting"), "Executing RedirectResult, redirecting to {Destination}."); _redirectToRouteResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "RedirectToRouteResultExecuting"), "Executing RedirectToRouteResult, redirecting to {Destination} from route {RouteName}."); _redirectToPageResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, "RedirectToPageResultExecuting"), "Executing RedirectToPageResult, redirecting to {Page}."); _noActionsMatched = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "NoActionsMatched"), "No actions matched the current request. Route values: {RouteValues}"); _featureNotFound = LoggerMessage.Define( LogLevel.Warning, - 1, + new EventId(1, "FeatureNotFound"), "A request body size limit could not be applied. This server does not support the IHttpRequestBodySizeFeature."); _featureIsReadOnly = LoggerMessage.Define( LogLevel.Warning, - 2, + new EventId(2, "FeatureIsReadOnly"), "A request body size limit could not be applied. The IHttpRequestBodySizeFeature for the server is read-only."); _maxRequestBodySizeSet = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "MaxRequestBodySizeSet"), "The maximum request body size has been set to {RequestSize}."); _requestBodySizeLimitDisabled = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "RequestBodySizeLimitDisabled"), "The request body size limit has been disabled."); _cannotApplyRequestFormLimits = LoggerMessage.Define( LogLevel.Warning, - 1, + new EventId(1, "CannotApplyRequestFormLimits"), "Unable to apply configured form options since the request form has already been read."); _appliedRequestFormLimits = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, "AppliedRequestFormLimits"), "Applied the configured form options on the current request."); _modelStateInvalidFilterExecuting = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, "ModelStateInvalidFilterExecuting"), "The request has model state errors, returning an error response."); _inferredParameterSource = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, "InferredParameterSource"), "Inferred binding source for '{ParameterName}` on `{ActionName}` as {BindingSource}."); _unsupportedFormatFilterContentType = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, "UnsupportedFormatFilterContentType"), "Could not find a media type for the format '{FormatFilterContentType}'."); _actionDoesNotSupportFormatFilterContentType = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, "ActionDoesNotSupportFormatFilterContentType"), "Current action does not support the content type '{FormatFilterContentType}'. The supported content types are '{SupportedMediaTypes}'."); _cannotApplyFormatFilterContentType = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, "CannotApplyFormatFilterContentType"), "Cannot apply content type '{FormatFilterContentType}' to the response as current action had explicitly set a preferred content type."); _notMostEffectiveFilter = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, "NotMostEffectiveFilter"), "Execution of filter {OverriddenFilter} is preempted by filter {OverridingFilter} which is the most effective filter implementing policy {FilterPolicy}."); _actionDoesNotExplicitlySpecifyContentTypes = LoggerMessage.Define( LogLevel.Debug, - 5, + new EventId(5, "ActionDoesNotExplicitlySpecifyContentTypes"), "Current action does not explicitly specify any content types for the response."); _selectingOutputFormatterUsingAcceptHeader = LoggerMessage.Define>( LogLevel.Debug, - 6, + new EventId(6, "SelectingOutputFormatterUsingAcceptHeader"), "Attempting to select an output formatter based on Accept header '{AcceptHeader}'."); _selectingOutputFormatterUsingAcceptHeaderAndExplicitContentTypes = LoggerMessage.Define, MediaTypeCollection>( LogLevel.Debug, - 7, + new EventId(7, "SelectingOutputFormatterUsingAcceptHeaderAndExplicitContentTypes"), "Attempting to select an output formatter based on Accept header '{AcceptHeader}' and explicitly specified content types '{ExplicitContentTypes}'. The content types in the accept header must be a subset of the explicitly set content types."); _selectingOutputFormatterWithoutUsingContentTypes = LoggerMessage.Define( LogLevel.Debug, - 8, + new EventId(8, "SelectingOutputFormatterWithoutUsingContentTypes"), "Attempting to select an output formatter without using a content type as no explicit content types were specified for the response."); _selectingOutputFormatterUsingContentTypes = LoggerMessage.Define( LogLevel.Debug, - 9, + new EventId(9, "SelectingOutputFormatterUsingContentTypes"), "Attempting to select the first output formatter in the output formatters list which supports a content type from the explicitly specified content types '{ExplicitContentTypes}'."); _selectingFirstCanWriteFormatter = LoggerMessage.Define( LogLevel.Debug, - 10, + new EventId(10, "SelectingFirstCanWriteFormatter"), "Attempting to select the first formatter in the output formatters list which can write the result."); _registeredOutputFormatters = LoggerMessage.Define>( LogLevel.Debug, - 11, + new EventId(11, "RegisteredOutputFormatters"), "List of registered output formatters, in the following order: {OutputFormatters}"); _writingRangeToBody = LoggerMessage.Define( LogLevel.Debug, - 17, + new EventId(17, "WritingRangeToBody"), "Writing the requested range of bytes to the body..."); _registeredModelBinderProviders = LoggerMessage.Define( LogLevel.Debug, - 12, + new EventId(12, "RegisteredModelBinderProviders"), "Registered model binder providers, in the following order: {ModelBinderProviders}"); _attemptingToBindPropertyModel = LoggerMessage.Define( LogLevel.Debug, - 13, + new EventId(13, "AttemptingToBindPropertyModel"), "Attempting to bind property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}' using the name '{ModelName}' in request data ..."); _doneAttemptingToBindPropertyModel = LoggerMessage.Define( LogLevel.Debug, - 14, + new EventId(14, "DoneAttemptingToBindPropertyModel"), "Done attempting to bind property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}'."); _foundNoValueForPropertyInRequest = LoggerMessage.Define( LogLevel.Debug, - 15, + new EventId(15, "FoundNoValueForPropertyInRequest"), "Could not find a value in the request with name '{ModelName}' for binding property '{PropertyContainerType}.{ModelFieldName}' of type '{ModelType}'."); _foundNoValueForParameterInRequest = LoggerMessage.Define( LogLevel.Debug, - 16, + new EventId(16, "FoundNoValueForParameterInRequest"), "Could not find a value in the request with name '{ModelName}' for binding parameter '{ModelFieldName}' of type '{ModelType}'."); _noPublicSettableProperties = LoggerMessage.Define( LogLevel.Debug, - 17, + new EventId(17, "NoPublicSettableProperties"), "Could not bind to model with name '{ModelName}' and type '{ModelType}' as the type has no public settable properties."); _cannotBindToComplexType = LoggerMessage.Define( LogLevel.Debug, - 18, + new EventId(18, "CannotBindToComplexType"), "Could not bind to model of type '{ModelType}' as there were no values in the request for any of the properties."); _cannotBindToFilesCollectionDueToUnsupportedContentType = LoggerMessage.Define( LogLevel.Debug, - 19, + new EventId(19, "CannotBindToFilesCollectionDueToUnsupportedContentType"), "Could not bind to model with name '{ModelName}' and type '{ModelType}' as the request did not have a content type of either 'application/x-www-form-urlencoded' or 'multipart/form-data'."); _cannotCreateHeaderModelBinder = LoggerMessage.Define( LogLevel.Debug, - 20, + new EventId(20, "CannotCreateHeaderModelBinder"), "Could not create a binder for type '{ModelType}' as this binder only supports simple types (like string, int, bool, enum) or a collection of simple types."); _noFilesFoundInRequest = LoggerMessage.Define( LogLevel.Debug, - 21, + new EventId(21, "NoFilesFoundInRequest"), "No files found in the request to bind the model to."); _attemptingToBindParameter = LoggerMessage.Define( LogLevel.Debug, - 22, + new EventId(22, "AttemptingToBindParameter"), "Attempting to bind parameter '{ParameterName}' of type '{ModelType}' ..."); _doneAttemptingToBindParameter = LoggerMessage.Define( LogLevel.Debug, - 23, + new EventId(23, "DoneAttemptingToBindParameter"), "Done attempting to bind parameter '{ParameterName}' of type '{ModelType}'."); _attemptingToBindModel = LoggerMessage.Define( LogLevel.Debug, - 24, + new EventId(24, "AttemptingToBindModel"), "Attempting to bind model of type '{ModelType}' using the name '{ModelName}' in request data ..."); _doneAttemptingToBindModel = LoggerMessage.Define( LogLevel.Debug, - 25, + new EventId(25, "DoneAttemptingToBindModel"), "Done attempting to bind model of type '{ModelType}' using the name '{ModelName}'."); _attemptingToValidateParameter = LoggerMessage.Define( LogLevel.Debug, - 26, + new EventId(26, "AttemptingToValidateParameter"), "Attempting to validate the bound parameter '{ParameterName}' of type '{ModelType}' ..."); _doneAttemptingToValidateParameter = LoggerMessage.Define( LogLevel.Debug, - 27, + new EventId(27, "DoneAttemptingToValidateParameter"), "Done attempting to validate the bound parameter '{ParameterName}' of type '{ModelType}'."); _noNonIndexBasedFormatFoundForCollection = LoggerMessage.Define( LogLevel.Debug, - 28, + new EventId(28, "NoNonIndexBasedFormatFoundForCollection"), "Could not bind to collection using a format like {ModelName}=value1&{ModelName}=value2"); _attemptingToBindCollectionUsingIndices = LoggerMessage.Define( LogLevel.Debug, - 29, + new EventId(29, "AttemptingToBindCollectionUsingIndices"), "Attempting to bind model using indices. Example formats include: " + "[0]=value1&[1]=value2, " + "{ModelName}[0]=value1&{ModelName}[1]=value2, " + @@ -564,7 +564,7 @@ namespace Microsoft.AspNetCore.Mvc _attemptingToBindCollectionOfKeyValuePair = LoggerMessage.Define( LogLevel.Debug, - 30, + new EventId(30, "AttemptingToBindCollectionOfKeyValuePair"), "Attempting to bind collection of KeyValuePair. Example formats include: " + "[0].Key=key1&[0].Value=value1&[1].Key=key2&[1].Value=value2, " + "{ModelName}[0].Key=key1&{ModelName}[0].Value=value1&{ModelName}[1].Key=key2&{ModelName}[1].Value=value2, " + @@ -572,82 +572,82 @@ namespace Microsoft.AspNetCore.Mvc _noKeyValueFormatForDictionaryModelBinder = LoggerMessage.Define( LogLevel.Debug, - 33, + new EventId(33, "NoKeyValueFormatForDictionaryModelBinder"), "Attempting to bind model with name '{ModelName}' using the format {ModelName}[key1]=value1&{ModelName}[key2]=value2"); _ifMatchPreconditionFailed = LoggerMessage.Define( LogLevel.Debug, - 34, + new EventId(34, "IfMatchPreconditionFailed"), "Current request's If-Match header check failed as the file's current etag '{CurrentETag}' does not match with any of the supplied etags."); _ifUnmodifiedSincePreconditionFailed = LoggerMessage.Define( LogLevel.Debug, - 35, + new EventId(35, "IfUnmodifiedSincePreconditionFailed"), "Current request's If-Unmodified-Since header check failed as the file was modified (at '{lastModified}') after the If-Unmodified-Since date '{IfUnmodifiedSinceDate}'."); _ifRangeLastModifiedPreconditionFailed = LoggerMessage.Define( LogLevel.Debug, - 36, + new EventId(36, "IfRangeLastModifiedPreconditionFailed"), "Could not serve range as the file was modified (at {LastModified}) after the if-Range's last modified date '{IfRangeLastModified}'."); _ifRangeETagPreconditionFailed = LoggerMessage.Define( LogLevel.Debug, - 37, + new EventId(37, "IfRangeETagPreconditionFailed"), "Could not serve range as the file's current etag '{CurrentETag}' does not match the If-Range etag '{IfRangeETag}'."); _notEnabledForRangeProcessing = LoggerMessage.Define( LogLevel.Debug, - 38, + new EventId(38, "NotEnabledForRangeProcessing"), $"The file result has not been enabled for processing range requests. To enable it, set the property '{nameof(FileResult.EnableRangeProcessing)}' on the result to 'true'."); _attemptingToBindProperty = LoggerMessage.Define( LogLevel.Debug, - 39, + new EventId(39, "AttemptingToBindProperty"), "Attempting to bind property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}' ..."); _doneAttemptingToBindProperty = LoggerMessage.Define( LogLevel.Debug, - 40, + new EventId(40, "DoneAttemptingToBindProperty"), "Done attempting to bind property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}'."); _attemptingToValidateProperty = LoggerMessage.Define( LogLevel.Debug, - 41, + new EventId(41, "AttemptingToValidateProperty"), "Attempting to validate the bound property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}' ..."); _doneAttemptingToValidateProperty = LoggerMessage.Define( LogLevel.Debug, - 42, + new EventId(42, "DoneAttemptingToValidateProperty"), "Done attempting to validate the bound property '{PropertyContainerType}.{PropertyName}' of type '{ModelType}'."); _cannotCreateHeaderModelBinderCompatVersion_2_0 = LoggerMessage.Define( LogLevel.Debug, - 43, + new EventId(43, "CannotCreateHeaderModelBinderCompatVersion20"), "Could not create a binder for type '{ModelType}' as this binder only supports 'System.String' type or a collection of 'System.String'."); _attemptingToBindParameterModel = LoggerMessage.Define( LogLevel.Debug, - 44, + new EventId(44, "AttemptingToBindParameterModel"), "Attempting to bind parameter '{ParameterName}' of type '{ModelType}' using the name '{ModelName}' in request data ..."); _doneAttemptingToBindParameterModel = LoggerMessage.Define( LogLevel.Debug, - 45, + new EventId(45, "DoneAttemptingToBindParameterModel"), "Done attempting to bind parameter '{ParameterName}' of type '{ModelType}'."); _foundNoValueInRequest = LoggerMessage.Define( LogLevel.Debug, - 46, + new EventId(46, "FoundNoValueInRequest"), "Could not find a value in the request with name '{ModelName}' of type '{ModelType}'."); _parameterBinderRequestPredicateShortCircuitOfProperty = LoggerMessage.Define( LogLevel.Debug, - 47, + new EventId(47, "ParameterBinderRequestPredicateShortCircuitOfProperty"), "Skipped binding property '{PropertyContainerType}.{PropertyName}' since its binding information disallowed it for the current request."); _parameterBinderRequestPredicateShortCircuitOfParameter = LoggerMessage.Define( LogLevel.Debug, - 48, + new EventId(48, "ParameterBinderRequestPredicateShortCircuitOfParameter"), "Skipped binding parameter '{ParameterName}' since its binding information disallowed it for the current request."); _transformingClientError = LoggerMessage.Define( diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Cors/CorsLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Cors/CorsLoggerExtensions.cs index 8bc4af91f4..39eb058613 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Cors/CorsLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Cors/CorsLoggerExtensions.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors { _notMostEffectiveFilter = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(NotMostEffectiveFilter)), "Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}."); } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonLoggerExtensions.cs index c4f15f190a..559e0aec93 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonLoggerExtensions.cs @@ -16,12 +16,12 @@ namespace Microsoft.AspNetCore.Mvc.Formatters { _jsonInputFormatterCrashed = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(JsonInputException)), "JSON input formatter threw an exception."); _jsonResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, nameof(JsonResultExecuting)), "Executing JsonResult, writing value of type '{Type}'."); } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/LoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/LoggerExtensions.cs index 76496bea3a..80f5c2d03f 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/LoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/LoggerExtensions.cs @@ -15,12 +15,12 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml { _failedToCreateXmlSerializer = LoggerMessage.Define( LogLevel.Warning, - 1, + new EventId(1, nameof(FailedToCreateXmlSerializer)), "An error occurred while trying to create an XmlSerializer for the type '{Type}'."); _failedToCreateDataContractSerializer = LoggerMessage.Define( LogLevel.Warning, - 2, + new EventId(2, nameof(FailedToCreateDataContractSerializer)), "An error occurred while trying to create a DataContractSerializer for the type '{Type}'."); } @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml { _failedToCreateXmlSerializer(logger, typeName, exception); } - + public static void FailedToCreateDataContractSerializer(this ILogger logger, string typeName, Exception exception) { _failedToCreateDataContractSerializer(logger, typeName, exception); diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorLoggerExtensions.cs index 58a1123cc7..39072cb1d7 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorLoggerExtensions.cs @@ -36,87 +36,82 @@ namespace Microsoft.AspNetCore.Mvc.Razor { _viewCompilerStartCodeGeneration = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(ViewCompilerStartCodeGeneration)), "Code generation for the Razor file at '{FilePath}' started."); _viewCompilerEndCodeGeneration = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(ViewCompilerEndCodeGeneration)), "Code generation for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); _viewCompilerLocatedCompiledView = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, nameof(ViewCompilerLocatedCompiledView)), "Initializing Razor view compiler with compiled view: '{ViewName}'."); _viewCompilerNoCompiledViewsFound = LoggerMessage.Define( LogLevel.Debug, - 4, + new EventId(4, nameof(ViewCompilerNoCompiledViewsFound)), "Initializing Razor view compiler with no compiled views."); _viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define( LogLevel.Trace, - 5, - "Located compiled view for view at path '{Path}'."); - - _viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define( - LogLevel.Trace, - 5, + new EventId(5, nameof(ViewCompilerLocatedCompiledViewForPath)), "Located compiled view for view at path '{Path}'."); _viewCompilerRecompilingCompiledView = LoggerMessage.Define( LogLevel.Trace, - 6, + new EventId(6, "ViewCompilerRecompilingCompiledView"), "Invalidating compiled view for view at path '{Path}'."); _viewCompilerCouldNotFindFileToCompileForPath = LoggerMessage.Define( LogLevel.Trace, - 7, + new EventId(7, nameof(ViewCompilerCouldNotFindFileAtPath)), "Could not find a file for view at path '{Path}'."); _viewCompilerFoundFileToCompileForPath = LoggerMessage.Define( LogLevel.Trace, - 8, + new EventId(8, nameof(ViewCompilerFoundFileToCompile)), "Found file at path '{Path}'."); _viewCompilerInvalidatingCompiledFile = LoggerMessage.Define( LogLevel.Trace, - 9, + new EventId(9, nameof(ViewCompilerInvalidingCompiledFile)), "Invalidating compiled view at path '{Path}' with a file since the checksum did not match."); _viewLookupCacheMiss = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(ViewLookupCacheMiss)), "View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'."); _viewLookupCacheHit = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(ViewLookupCacheHit)), "View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'."); _precompiledViewFound = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, nameof(PrecompiledViewFound)), "Using precompiled view for '{RelativePath}'."); _generatedCodeToAssemblyCompilationStart = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(GeneratedCodeToAssemblyCompilationStart)), "Compilation of the generated code for the Razor file at '{FilePath}' started."); _generatedCodeToAssemblyCompilationEnd = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(GeneratedCodeToAssemblyCompilationEnd)), "Compilation of the generated code for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); _tagHelperComponentInitialized = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(TagHelperComponentInitialized)), "Tag helper component '{ComponentName}' initialized."); _tagHelperComponentProcessed = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, nameof(TagHelperComponentProcessed)), "Tag helper component '{ComponentName}' processed."); } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/PageLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/PageLoggerExtensions.cs index 2407767fc7..7de4b8679b 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/PageLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/PageLoggerExtensions.cs @@ -30,52 +30,52 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages _handlerMethodExecuting = LoggerMessage.Define( LogLevel.Information, - 101, + new EventId(101, nameof(ExecutingHandlerMethod)), "Executing handler method {HandlerName} with arguments ({Arguments}) - ModelState is {ValidationState}"); _handlerMethodExecuted = LoggerMessage.Define( LogLevel.Information, - 102, + new EventId(102, nameof(ExecutedHandlerMethod)), "Executed handler method {HandlerName}, returned result {ActionResult}."); _implicitHandlerMethodExecuting = LoggerMessage.Define( LogLevel.Information, - 103, + new EventId(103, nameof(ExecutingImplicitHandlerMethod)), "Executing an implicit handler method - ModelState is {ValidationState}"); _implicitHandlerMethodExecuted = LoggerMessage.Define( LogLevel.Information, - 104, + new EventId(104, nameof(ExecutedImplicitHandlerMethod)), "Executed an implicit handler method, returned result {ActionResult}."); _pageFilterShortCircuit = LoggerMessage.Define( LogLevel.Debug, - 3, + new EventId(3, nameof(PageFilterShortCircuited)), "Request was short circuited at page filter '{PageFilter}'."); _malformedPageDirective = LoggerMessage.Define( LogLevel.Warning, - 104, + new EventId(104, "MalformedPageDirective"), "The page directive at '{FilePath}' is malformed. Please fix the following issues: {Diagnostics}"); _notMostEffectiveFilter = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(NotMostEffectiveFilter)), "Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}."); _beforeExecutingMethodOnFilter = LoggerMessage.Define( LogLevel.Trace, - 1, + new EventId(1, nameof(BeforeExecutingMethodOnFilter)), "{FilterType}: Before executing {Method} on filter {Filter}."); _afterExecutingMethodOnFilter = LoggerMessage.Define( LogLevel.Trace, - 2, + new EventId(2, nameof(AfterExecutingMethodOnFilter)), "{FilterType}: After executing {Method} on filter {Filter}."); _unsupportedAreaPath = LoggerMessage.Define( LogLevel.Warning, - 1, + new EventId(1, nameof(UnsupportedAreaPath)), "The page at '{FilePath}' is located under the area root directory '/Areas/' but does not follow the path format '/Areas/AreaName/Pages/Directory/FileName.cshtml"); } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.TagHelpers/MvcTagHelpersLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.TagHelpers/MvcTagHelpersLoggerExtensions.cs index 7a78c67530..ed33b73382 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.TagHelpers/MvcTagHelpersLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.TagHelpers/MvcTagHelpersLoggerExtensions.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers { _distributedFormatterDeserializedFailed = LoggerMessage.Define( LogLevel.Error, - 1, + new EventId(1, nameof(DistributedFormatterDeserializationException)), "Couldn't deserialize cached value for key {Key}."); } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesLoggerExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesLoggerExtensions.cs index 070d4ec775..ad03bd3b18 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesLoggerExtensions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesLoggerExtensions.cs @@ -42,83 +42,83 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures { _viewComponentExecuting = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(ViewComponentExecuting)), "Executing view component {ViewComponentName} with arguments ({Arguments})."); _viewComponentExecuted = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(ViewComponentExecuted)), "Executed view component {ViewComponentName} in {ElapsedMilliseconds}ms and returned " + "{ViewComponentResult}"); _partialViewResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, nameof(PartialViewResultExecuting)), "Executing PartialViewResult, running view {PartialViewName}."); _partialViewFound = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(PartialViewFound)), "The partial view path '{PartialViewFilePath}' was found in {ElapsedMilliseconds}ms."); _partialViewNotFound = LoggerMessage.Define>( LogLevel.Error, - 3, + new EventId(3, nameof(PartialViewNotFound)), "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}"); _partialViewResultExecuted = LoggerMessage.Define( LogLevel.Information, - 4, + new EventId(4, nameof(PartialViewResultExecuted)), "Executed PartialViewResult - view {PartialViewName} executed in {ElapsedMilliseconds}ms."); _antiforgeryTokenInvalid = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, nameof(AntiforgeryTokenInvalid)), "Antiforgery token validation failed. {Message}"); _viewComponentResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, nameof(ViewComponentResultExecuting)), "Executing ViewComponentResult, running {ViewComponentName}."); _viewResultExecuting = LoggerMessage.Define( LogLevel.Information, - 1, + new EventId(1, nameof(ViewResultExecuting)), "Executing ViewResult, running view {ViewName}."); _viewFound = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(ViewFound)), "The view path '{ViewFilePath}' was found in {ElapsedMilliseconds}ms."); _viewNotFound = LoggerMessage.Define>( LogLevel.Error, - 3, + new EventId(3, nameof(ViewNotFound)), "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}"); _viewResultExecuted = LoggerMessage.Define( LogLevel.Information, - 4, + new EventId(4, nameof(ViewResultExecuted)), "Executed ViewResult - view {ViewName} executed in {ElapsedMilliseconds}ms."); _tempDataCookieNotFound = LoggerMessage.Define( LogLevel.Debug, - 1, + new EventId(1, nameof(TempDataCookieNotFound)), "The temp data cookie {CookieName} was not found."); _tempDataCookieLoadSuccess = LoggerMessage.Define( LogLevel.Debug, - 2, + new EventId(2, nameof(TempDataCookieLoadSuccess)), "The temp data cookie {CookieName} was used to successfully load temp data."); _tempDataCookieLoadFailure = LoggerMessage.Define( LogLevel.Warning, - 3, + new EventId(3, nameof(TempDataCookieLoadFailure)), "The temp data cookie {CookieName} could not be loaded."); _notMostEffectiveFilter = LoggerMessage.Define( LogLevel.Trace, - 1, + new EventId(1, nameof(NotMostEffectiveFilter)), "Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}."); }