Add event name in Middlewares (#6467)

This commit is contained in:
Kahbazi 2019-01-09 07:56:58 +03:30 committed by James Newton-King
parent 688ad19170
commit 3c9cb4f3b5
14 changed files with 319 additions and 259 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -25,47 +25,47 @@ namespace Microsoft.AspNetCore.Cors.Internal
{ {
_isPreflightRequest = LoggerMessage.Define( _isPreflightRequest = LoggerMessage.Define(
LogLevel.Debug, LogLevel.Debug,
1, new EventId(1, "IsPreflightRequest"),
"The request is a preflight request."); "The request is a preflight request.");
_requestHasOriginHeader = LoggerMessage.Define<string>( _requestHasOriginHeader = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
2, new EventId(2, "RequestHasOriginHeader"),
"The request has an origin header: '{origin}'."); "The request has an origin header: '{origin}'.");
_requestDoesNotHaveOriginHeader = LoggerMessage.Define( _requestDoesNotHaveOriginHeader = LoggerMessage.Define(
LogLevel.Debug, LogLevel.Debug,
3, new EventId(3, "RequestDoesNotHaveOriginHeader"),
"The request does not have an origin header."); "The request does not have an origin header.");
_policySuccess = LoggerMessage.Define( _policySuccess = LoggerMessage.Define(
LogLevel.Information, LogLevel.Information,
4, new EventId(4, "PolicySuccess"),
"CORS policy execution successful."); "CORS policy execution successful.");
_policyFailure = LoggerMessage.Define( _policyFailure = LoggerMessage.Define(
LogLevel.Information, LogLevel.Information,
5, new EventId(5, "PolicyFailure"),
"CORS policy execution failed."); "CORS policy execution failed.");
_originNotAllowed = LoggerMessage.Define<string>( _originNotAllowed = LoggerMessage.Define<string>(
LogLevel.Information, LogLevel.Information,
6, new EventId(6, "OriginNotAllowed"),
"Request origin {origin} does not have permission to access the resource."); "Request origin {origin} does not have permission to access the resource.");
_accessControlMethodNotAllowed = LoggerMessage.Define<string>( _accessControlMethodNotAllowed = LoggerMessage.Define<string>(
LogLevel.Information, LogLevel.Information,
7, new EventId(7, "AccessControlMethodNotAllowed"),
"Request method {accessControlRequestMethod} not allowed in CORS policy."); "Request method {accessControlRequestMethod} not allowed in CORS policy.");
_requestHeaderNotAllowed = LoggerMessage.Define<string>( _requestHeaderNotAllowed = LoggerMessage.Define<string>(
LogLevel.Information, LogLevel.Information,
8, new EventId(8, "RequestHeaderNotAllowed"),
"Request header '{requestHeader}' not allowed in CORS policy."); "Request header '{requestHeader}' not allowed in CORS policy.");
_failedToSetCorsHeaders = LoggerMessage.Define( _failedToSetCorsHeaders = LoggerMessage.Define(
LogLevel.Warning, LogLevel.Warning,
9, new EventId(9, "FailedToSetCorsHeaders"),
"Failed to apply CORS Response headers."); "Failed to apply CORS Response headers.");
_noCorsPolicyFound = LoggerMessage.Define( _noCorsPolicyFound = LoggerMessage.Define(
@ -75,12 +75,12 @@ namespace Microsoft.AspNetCore.Cors.Internal
_insecureConfiguration = LoggerMessage.Define( _insecureConfiguration = LoggerMessage.Define(
LogLevel.Warning, LogLevel.Warning,
new EventId(11, "CorsInsecureConfiguration"), new EventId(11, "InsecureConfiguration"),
"The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the policy by listing individual origins if credentials needs to be supported."); "The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the policy by listing individual origins if credentials needs to be supported.");
_isNotPreflightRequest = LoggerMessage.Define( _isNotPreflightRequest = LoggerMessage.Define(
LogLevel.Debug, LogLevel.Debug,
new EventId(12, "OptionsRequestWithoutAccessControlRequestMethodHeader"), new EventId(12, "IsNotPreflightRequest"),
"This request uses the HTTP OPTIONS method but does not have an Access-Control-Request-Method header. This request will not be treated as a CORS preflight request."); "This request uses the HTTP OPTIONS method but does not have an Access-Control-Request-Method header. This request will not be treated as a CORS preflight request.");
} }

View File

@ -14,9 +14,20 @@ namespace Microsoft.AspNetCore.HttpsPolicy.Internal
static HstsLoggingExtensions() static HstsLoggingExtensions()
{ {
_notSecure = LoggerMessage.Define(LogLevel.Debug, 1, "The request is insecure. Skipping HSTS header."); _notSecure = LoggerMessage.Define(
_excludedHost = LoggerMessage.Define<string>(LogLevel.Debug, 2, "The host '{host}' is excluded. Skipping HSTS header."); LogLevel.Debug,
_addingHstsHeader = LoggerMessage.Define(LogLevel.Trace, 3, "Adding HSTS header to response."); new EventId(1, "NotSecure"),
"The request is insecure. Skipping HSTS header.");
_excludedHost = LoggerMessage.Define<string>(
LogLevel.Debug,
new EventId(2, "ExcludedHost"),
"The host '{host}' is excluded. Skipping HSTS header.");
_addingHstsHeader = LoggerMessage.Define(
LogLevel.Trace,
new EventId(3, "AddingHstsHeader"),
"Adding HSTS header to response.");
} }
public static void SkippingInsecure(this ILogger logger) public static void SkippingInsecure(this ILogger logger)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -16,13 +16,31 @@ namespace Microsoft.AspNetCore.HttpsPolicy.Internal
static HttpsLoggingExtensions() static HttpsLoggingExtensions()
{ {
_redirectingToHttps = LoggerMessage.Define<string>(LogLevel.Debug, 1, "Redirecting to '{redirect}'."); _redirectingToHttps = LoggerMessage.Define<string>(
_portLoadedFromConfig = LoggerMessage.Define<int>(LogLevel.Debug, 2, "Https port '{port}' loaded from configuration."); LogLevel.Debug,
_failedToDeterminePort = LoggerMessage.Define(LogLevel.Warning, 3, "Failed to determine the https port for redirect."); new EventId(1, "RedirectingToHttps"),
_failedMultiplePorts = LoggerMessage.Define(LogLevel.Warning, 4, "Redirecting to '{redirect}'.");
_portLoadedFromConfig = LoggerMessage.Define<int>(
LogLevel.Debug,
new EventId(2, "PortLoadedFromConfig"),
"Https port '{port}' loaded from configuration.");
_failedToDeterminePort = LoggerMessage.Define(
LogLevel.Warning,
new EventId(3, "FailedToDeterminePort"),
"Failed to determine the https port for redirect.");
_failedMultiplePorts = LoggerMessage.Define(
LogLevel.Warning,
new EventId(4, "FailedMultiplePorts"),
"Cannot determine the https port from IServerAddressesFeature, multiple values were found. " + "Cannot determine the https port from IServerAddressesFeature, multiple values were found. " +
"Please set the desired port explicitly on HttpsRedirectionOptions.HttpsPort."); "Please set the desired port explicitly on HttpsRedirectionOptions.HttpsPort.");
_portFromServer = LoggerMessage.Define<int>(LogLevel.Debug, 5, "Https port '{httpsPort}' discovered from server endpoints.");
_portFromServer = LoggerMessage.Define<int>(
LogLevel.Debug,
new EventId(5, "PortFromServer"),
"Https port '{httpsPort}' discovered from server endpoints.");
} }
public static void RedirectingToHttps(this ILogger logger, string redirect) public static void RedirectingToHttps(this ILogger logger, string redirect)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -17,11 +17,11 @@ namespace Microsoft.AspNetCore.Localization.Internal
{ {
_unsupportedCulture = LoggerMessage.Define<string, IList<StringSegment>>( _unsupportedCulture = LoggerMessage.Define<string, IList<StringSegment>>(
LogLevel.Warning, LogLevel.Warning,
1, new EventId (1, "UnsupportedCulture"),
"{requestCultureProvider} returned the following unsupported cultures '{cultures}'."); "{requestCultureProvider} returned the following unsupported cultures '{cultures}'.");
_unsupportedUICulture = LoggerMessage.Define<string, IList<StringSegment>>( _unsupportedUICulture = LoggerMessage.Define<string, IList<StringSegment>>(
LogLevel.Warning, LogLevel.Warning,
2, new EventId(2, "UnsupportedUICulture"),
"{requestCultureProvider} returned the following unsupported UI Cultures '{uiCultures}'."); "{requestCultureProvider} returned the following unsupported UI Cultures '{uiCultures}'.");
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -12,299 +12,299 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
/// </summary> /// </summary>
internal static class LoggerExtensions internal static class LoggerExtensions
{ {
private static readonly Action<ILogger, string, Exception> _logRequestMethodNotCacheable; private static readonly Action<ILogger, string, Exception> _requestMethodNotCacheable;
private static readonly Action<ILogger, Exception> _logRequestWithAuthorizationNotCacheable; private static readonly Action<ILogger, Exception> _requestWithAuthorizationNotCacheable;
private static readonly Action<ILogger, Exception> _logRequestWithNoCacheNotCacheable; private static readonly Action<ILogger, Exception> _requestWithNoCacheNotCacheable;
private static readonly Action<ILogger, Exception> _logRequestWithPragmaNoCacheNotCacheable; private static readonly Action<ILogger, Exception> _requestWithPragmaNoCacheNotCacheable;
private static readonly Action<ILogger, TimeSpan, Exception> _logExpirationMinFreshAdded; private static readonly Action<ILogger, TimeSpan, Exception> _expirationMinFreshAdded;
private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _logExpirationSharedMaxAgeExceeded; private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _expirationSharedMaxAgeExceeded;
private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _logExpirationMustRevalidate; private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _expirationMustRevalidate;
private static readonly Action<ILogger, TimeSpan, TimeSpan, TimeSpan, Exception> _logExpirationMaxStaleSatisfied; private static readonly Action<ILogger, TimeSpan, TimeSpan, TimeSpan, Exception> _expirationMaxStaleSatisfied;
private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _logExpirationMaxAgeExceeded; private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _expirationMaxAgeExceeded;
private static readonly Action<ILogger, DateTimeOffset, DateTimeOffset, Exception> _logExpirationExpiresExceeded; private static readonly Action<ILogger, DateTimeOffset, DateTimeOffset, Exception> _expirationExpiresExceeded;
private static readonly Action<ILogger, Exception> _logResponseWithoutPublicNotCacheable; private static readonly Action<ILogger, Exception> _responseWithoutPublicNotCacheable;
private static readonly Action<ILogger, Exception> _logResponseWithNoStoreNotCacheable; private static readonly Action<ILogger, Exception> _responseWithNoStoreNotCacheable;
private static readonly Action<ILogger, Exception> _logResponseWithNoCacheNotCacheable; private static readonly Action<ILogger, Exception> _responseWithNoCacheNotCacheable;
private static readonly Action<ILogger, Exception> _logResponseWithSetCookieNotCacheable; private static readonly Action<ILogger, Exception> _responseWithSetCookieNotCacheable;
private static readonly Action<ILogger, Exception> _logResponseWithVaryStarNotCacheable; private static readonly Action<ILogger, Exception> _responseWithVaryStarNotCacheable;
private static readonly Action<ILogger, Exception> _logResponseWithPrivateNotCacheable; private static readonly Action<ILogger, Exception> _responseWithPrivateNotCacheable;
private static readonly Action<ILogger, int, Exception> _logResponseWithUnsuccessfulStatusCodeNotCacheable; private static readonly Action<ILogger, int, Exception> _responseWithUnsuccessfulStatusCodeNotCacheable;
private static readonly Action<ILogger, Exception> _logNotModifiedIfNoneMatchStar; private static readonly Action<ILogger, Exception> _notModifiedIfNoneMatchStar;
private static readonly Action<ILogger, EntityTagHeaderValue, Exception> _logNotModifiedIfNoneMatchMatched; private static readonly Action<ILogger, EntityTagHeaderValue, Exception> _notModifiedIfNoneMatchMatched;
private static readonly Action<ILogger, DateTimeOffset, DateTimeOffset, Exception> _logNotModifiedIfModifiedSinceSatisfied; private static readonly Action<ILogger, DateTimeOffset, DateTimeOffset, Exception> _notModifiedIfModifiedSinceSatisfied;
private static readonly Action<ILogger, Exception> _logNotModifiedServed; private static readonly Action<ILogger, Exception> _notModifiedServed;
private static readonly Action<ILogger, Exception> _logCachedResponseServed; private static readonly Action<ILogger, Exception> _cachedResponseServed;
private static readonly Action<ILogger, Exception> _logGatewayTimeoutServed; private static readonly Action<ILogger, Exception> _gatewayTimeoutServed;
private static readonly Action<ILogger, Exception> _logNoResponseServed; private static readonly Action<ILogger, Exception> _noResponseServed;
private static readonly Action<ILogger, string, string, Exception> _logVaryByRulesUpdated; private static readonly Action<ILogger, string, string, Exception> _varyByRulesUpdated;
private static readonly Action<ILogger, Exception> _logResponseCached; private static readonly Action<ILogger, Exception> _responseCached;
private static readonly Action<ILogger, Exception> _logResponseNotCached; private static readonly Action<ILogger, Exception> _responseNotCached;
private static readonly Action<ILogger, Exception> _logResponseContentLengthMismatchNotCached; private static readonly Action<ILogger, Exception> _responseContentLengthMismatchNotCached;
private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _logExpirationInfiniteMaxStaleSatisfied; private static readonly Action<ILogger, TimeSpan, TimeSpan, Exception> _expirationInfiniteMaxStaleSatisfied;
static LoggerExtensions() static LoggerExtensions()
{ {
_logRequestMethodNotCacheable = LoggerMessage.Define<string>( _requestMethodNotCacheable = LoggerMessage.Define<string>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 1, eventId: new EventId(1, "RequestMethodNotCacheable"),
formatString: "The request cannot be served from cache because it uses the HTTP method: {Method}."); formatString: "The request cannot be served from cache because it uses the HTTP method: {Method}.");
_logRequestWithAuthorizationNotCacheable = LoggerMessage.Define( _requestWithAuthorizationNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 2, eventId: new EventId(2, "RequestWithAuthorizationNotCacheable"),
formatString: $"The request cannot be served from cache because it contains an '{HeaderNames.Authorization}' header."); formatString: $"The request cannot be served from cache because it contains an '{HeaderNames.Authorization}' header.");
_logRequestWithNoCacheNotCacheable = LoggerMessage.Define( _requestWithNoCacheNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 3, eventId: new EventId(3, "RequestWithNoCacheNotCacheable"),
formatString: "The request cannot be served from cache because it contains a 'no-cache' cache directive."); formatString: "The request cannot be served from cache because it contains a 'no-cache' cache directive.");
_logRequestWithPragmaNoCacheNotCacheable = LoggerMessage.Define( _requestWithPragmaNoCacheNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 4, eventId: new EventId(4, "RequestWithPragmaNoCacheNotCacheable"),
formatString: "The request cannot be served from cache because it contains a 'no-cache' pragma directive."); formatString: "The request cannot be served from cache because it contains a 'no-cache' pragma directive.");
_logExpirationMinFreshAdded = LoggerMessage.Define<TimeSpan>( _expirationMinFreshAdded = LoggerMessage.Define<TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 5, eventId: new EventId(5, "LogRequestMethodNotCacheable"),
formatString: "Adding a minimum freshness requirement of {Duration} specified by the 'min-fresh' cache directive."); formatString: "Adding a minimum freshness requirement of {Duration} specified by the 'min-fresh' cache directive.");
_logExpirationSharedMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>( _expirationSharedMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 6, eventId: new EventId(6, "ExpirationSharedMaxAgeExceeded"),
formatString: "The age of the entry is {Age} and has exceeded the maximum age for shared caches of {SharedMaxAge} specified by the 's-maxage' cache directive."); formatString: "The age of the entry is {Age} and has exceeded the maximum age for shared caches of {SharedMaxAge} specified by the 's-maxage' cache directive.");
_logExpirationMustRevalidate = LoggerMessage.Define<TimeSpan, TimeSpan>( _expirationMustRevalidate = LoggerMessage.Define<TimeSpan, TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 7, eventId: new EventId(7, "ExpirationMustRevalidate"),
formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. It must be revalidated because the 'must-revalidate' or 'proxy-revalidate' cache directive is specified."); formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. It must be revalidated because the 'must-revalidate' or 'proxy-revalidate' cache directive is specified.");
_logExpirationMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan, TimeSpan>( _expirationMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan, TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 8, eventId: new EventId(8, "ExpirationMaxStaleSatisfied"),
formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, it satisfied the maximum stale allowance of {MaxStale} specified by the 'max-stale' cache directive."); formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, it satisfied the maximum stale allowance of {MaxStale} specified by the 'max-stale' cache directive.");
_logExpirationMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>( _expirationMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 9, eventId: new EventId(9, "ExpirationMaxAgeExceeded"),
formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive."); formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive.");
_logExpirationExpiresExceeded = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>( _expirationExpiresExceeded = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 10, eventId: new EventId(10, "ExpirationExpiresExceeded"),
formatString: $"The response time of the entry is {{ResponseTime}} and has exceeded the expiry date of {{Expired}} specified by the '{HeaderNames.Expires}' header."); formatString: $"The response time of the entry is {{ResponseTime}} and has exceeded the expiry date of {{Expired}} specified by the '{HeaderNames.Expires}' header.");
_logResponseWithoutPublicNotCacheable = LoggerMessage.Define( _responseWithoutPublicNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 11, eventId: new EventId(11, "ResponseWithoutPublicNotCacheable"),
formatString: "Response is not cacheable because it does not contain the 'public' cache directive."); formatString: "Response is not cacheable because it does not contain the 'public' cache directive.");
_logResponseWithNoStoreNotCacheable = LoggerMessage.Define( _responseWithNoStoreNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 12, eventId: new EventId(12, "ResponseWithNoStoreNotCacheable"),
formatString: "Response is not cacheable because it or its corresponding request contains a 'no-store' cache directive."); formatString: "Response is not cacheable because it or its corresponding request contains a 'no-store' cache directive.");
_logResponseWithNoCacheNotCacheable = LoggerMessage.Define( _responseWithNoCacheNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 13, eventId: new EventId(13, "ResponseWithNoCacheNotCacheable"),
formatString: "Response is not cacheable because it contains a 'no-cache' cache directive."); formatString: "Response is not cacheable because it contains a 'no-cache' cache directive.");
_logResponseWithSetCookieNotCacheable = LoggerMessage.Define( _responseWithSetCookieNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 14, eventId: new EventId(14, "ResponseWithSetCookieNotCacheable"),
formatString: $"Response is not cacheable because it contains a '{HeaderNames.SetCookie}' header."); formatString: $"Response is not cacheable because it contains a '{HeaderNames.SetCookie}' header.");
_logResponseWithVaryStarNotCacheable = LoggerMessage.Define( _responseWithVaryStarNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 15, eventId: new EventId(15, "ResponseWithVaryStarNotCacheable"),
formatString: $"Response is not cacheable because it contains a '{HeaderNames.Vary}' header with a value of *."); formatString: $"Response is not cacheable because it contains a '{HeaderNames.Vary}' header with a value of *.");
_logResponseWithPrivateNotCacheable = LoggerMessage.Define( _responseWithPrivateNotCacheable = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 16, eventId: new EventId(16, "ResponseWithPrivateNotCacheable"),
formatString: "Response is not cacheable because it contains the 'private' cache directive."); formatString: "Response is not cacheable because it contains the 'private' cache directive.");
_logResponseWithUnsuccessfulStatusCodeNotCacheable = LoggerMessage.Define<int>( _responseWithUnsuccessfulStatusCodeNotCacheable = LoggerMessage.Define<int>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 17, eventId: new EventId(17, "ResponseWithUnsuccessfulStatusCodeNotCacheable"),
formatString: "Response is not cacheable because its status code {StatusCode} does not indicate success."); formatString: "Response is not cacheable because its status code {StatusCode} does not indicate success.");
_logNotModifiedIfNoneMatchStar = LoggerMessage.Define( _notModifiedIfNoneMatchStar = LoggerMessage.Define(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 18, eventId: new EventId(18, "ExpirationExpiresExceeded"),
formatString: $"The '{HeaderNames.IfNoneMatch}' header of the request contains a value of *."); formatString: $"The '{HeaderNames.IfNoneMatch}' header of the request contains a value of *.");
_logNotModifiedIfNoneMatchMatched = LoggerMessage.Define<EntityTagHeaderValue>( _notModifiedIfNoneMatchMatched = LoggerMessage.Define<EntityTagHeaderValue>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 19, eventId: new EventId(19, "NotModifiedIfNoneMatchMatched"),
formatString: $"The ETag {{ETag}} in the '{HeaderNames.IfNoneMatch}' header matched the ETag of a cached entry."); formatString: $"The ETag {{ETag}} in the '{HeaderNames.IfNoneMatch}' header matched the ETag of a cached entry.");
_logNotModifiedIfModifiedSinceSatisfied = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>( _notModifiedIfModifiedSinceSatisfied = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 20, eventId: new EventId(20, "NotModifiedIfModifiedSinceSatisfied"),
formatString: $"The last modified date of {{LastModified}} is before the date {{IfModifiedSince}} specified in the '{HeaderNames.IfModifiedSince}' header."); formatString: $"The last modified date of {{LastModified}} is before the date {{IfModifiedSince}} specified in the '{HeaderNames.IfModifiedSince}' header.");
_logNotModifiedServed = LoggerMessage.Define( _notModifiedServed = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 21, eventId: new EventId(21, "NotModifiedServed"),
formatString: "The content requested has not been modified."); formatString: "The content requested has not been modified.");
_logCachedResponseServed = LoggerMessage.Define( _cachedResponseServed = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 22, eventId: new EventId(22, "CachedResponseServed"),
formatString: "Serving response from cache."); formatString: "Serving response from cache.");
_logGatewayTimeoutServed = LoggerMessage.Define( _gatewayTimeoutServed = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 23, eventId: new EventId(23, "GatewayTimeoutServed"),
formatString: "No cached response available for this request and the 'only-if-cached' cache directive was specified."); formatString: "No cached response available for this request and the 'only-if-cached' cache directive was specified.");
_logNoResponseServed = LoggerMessage.Define( _noResponseServed = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 24, eventId: new EventId(24, "NoResponseServed"),
formatString: "No cached response available for this request."); formatString: "No cached response available for this request.");
_logVaryByRulesUpdated = LoggerMessage.Define<string, string>( _varyByRulesUpdated = LoggerMessage.Define<string, string>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 25, eventId: new EventId(25, "VaryByRulesUpdated"),
formatString: "Vary by rules were updated. Headers: {Headers}, Query keys: {QueryKeys}"); formatString: "Vary by rules were updated. Headers: {Headers}, Query keys: {QueryKeys}");
_logResponseCached = LoggerMessage.Define( _responseCached = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 26, eventId: new EventId(26, "ResponseCached"),
formatString: "The response has been cached."); formatString: "The response has been cached.");
_logResponseNotCached = LoggerMessage.Define( _responseNotCached = LoggerMessage.Define(
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
eventId: 27, eventId: new EventId(27, "ResponseNotCached"),
formatString: "The response could not be cached for this request."); formatString: "The response could not be cached for this request.");
_logResponseContentLengthMismatchNotCached = LoggerMessage.Define( _responseContentLengthMismatchNotCached = LoggerMessage.Define(
logLevel: LogLevel.Warning, logLevel: LogLevel.Warning,
eventId: 28, eventId: new EventId(28, "responseContentLengthMismatchNotCached"),
formatString: $"The response could not be cached for this request because the '{HeaderNames.ContentLength}' did not match the body length."); formatString: $"The response could not be cached for this request because the '{HeaderNames.ContentLength}' did not match the body length.");
_logExpirationInfiniteMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan>( _expirationInfiniteMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan>(
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
eventId: 29, eventId: new EventId(29, "ExpirationInfiniteMaxStaleSatisfied"),
formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, the 'max-stale' cache directive was specified without an assigned value and a stale response of any age is accepted."); formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, the 'max-stale' cache directive was specified without an assigned value and a stale response of any age is accepted.");
} }
internal static void LogRequestMethodNotCacheable(this ILogger logger, string method) internal static void RequestMethodNotCacheable(this ILogger logger, string method)
{ {
_logRequestMethodNotCacheable(logger, method, null); _requestMethodNotCacheable(logger, method, null);
} }
internal static void LogRequestWithAuthorizationNotCacheable(this ILogger logger) internal static void RequestWithAuthorizationNotCacheable(this ILogger logger)
{ {
_logRequestWithAuthorizationNotCacheable(logger, null); _requestWithAuthorizationNotCacheable(logger, null);
} }
internal static void LogRequestWithNoCacheNotCacheable(this ILogger logger) internal static void RequestWithNoCacheNotCacheable(this ILogger logger)
{ {
_logRequestWithNoCacheNotCacheable(logger, null); _requestWithNoCacheNotCacheable(logger, null);
} }
internal static void LogRequestWithPragmaNoCacheNotCacheable(this ILogger logger) internal static void RequestWithPragmaNoCacheNotCacheable(this ILogger logger)
{ {
_logRequestWithPragmaNoCacheNotCacheable(logger, null); _requestWithPragmaNoCacheNotCacheable(logger, null);
} }
internal static void LogExpirationMinFreshAdded(this ILogger logger, TimeSpan duration) internal static void ExpirationMinFreshAdded(this ILogger logger, TimeSpan duration)
{ {
_logExpirationMinFreshAdded(logger, duration, null); _expirationMinFreshAdded(logger, duration, null);
} }
internal static void LogExpirationSharedMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan sharedMaxAge) internal static void ExpirationSharedMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan sharedMaxAge)
{ {
_logExpirationSharedMaxAgeExceeded(logger, age, sharedMaxAge, null); _expirationSharedMaxAgeExceeded(logger, age, sharedMaxAge, null);
} }
internal static void LogExpirationMustRevalidate(this ILogger logger, TimeSpan age, TimeSpan maxAge) internal static void ExpirationMustRevalidate(this ILogger logger, TimeSpan age, TimeSpan maxAge)
{ {
_logExpirationMustRevalidate(logger, age, maxAge, null); _expirationMustRevalidate(logger, age, maxAge, null);
} }
internal static void LogExpirationMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge, TimeSpan maxStale) internal static void ExpirationMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge, TimeSpan maxStale)
{ {
_logExpirationMaxStaleSatisfied(logger, age, maxAge, maxStale, null); _expirationMaxStaleSatisfied(logger, age, maxAge, maxStale, null);
} }
internal static void LogExpirationMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan sharedMaxAge) internal static void ExpirationMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan sharedMaxAge)
{ {
_logExpirationMaxAgeExceeded(logger, age, sharedMaxAge, null); _expirationMaxAgeExceeded(logger, age, sharedMaxAge, null);
} }
internal static void LogExpirationExpiresExceeded(this ILogger logger, DateTimeOffset responseTime, DateTimeOffset expires) internal static void ExpirationExpiresExceeded(this ILogger logger, DateTimeOffset responseTime, DateTimeOffset expires)
{ {
_logExpirationExpiresExceeded(logger, responseTime, expires, null); _expirationExpiresExceeded(logger, responseTime, expires, null);
} }
internal static void LogResponseWithoutPublicNotCacheable(this ILogger logger) internal static void ResponseWithoutPublicNotCacheable(this ILogger logger)
{ {
_logResponseWithoutPublicNotCacheable(logger, null); _responseWithoutPublicNotCacheable(logger, null);
} }
internal static void LogResponseWithNoStoreNotCacheable(this ILogger logger) internal static void ResponseWithNoStoreNotCacheable(this ILogger logger)
{ {
_logResponseWithNoStoreNotCacheable(logger, null); _responseWithNoStoreNotCacheable(logger, null);
} }
internal static void LogResponseWithNoCacheNotCacheable(this ILogger logger) internal static void ResponseWithNoCacheNotCacheable(this ILogger logger)
{ {
_logResponseWithNoCacheNotCacheable(logger, null); _responseWithNoCacheNotCacheable(logger, null);
} }
internal static void LogResponseWithSetCookieNotCacheable(this ILogger logger) internal static void ResponseWithSetCookieNotCacheable(this ILogger logger)
{ {
_logResponseWithSetCookieNotCacheable(logger, null); _responseWithSetCookieNotCacheable(logger, null);
} }
internal static void LogResponseWithVaryStarNotCacheable(this ILogger logger) internal static void ResponseWithVaryStarNotCacheable(this ILogger logger)
{ {
_logResponseWithVaryStarNotCacheable(logger, null); _responseWithVaryStarNotCacheable(logger, null);
} }
internal static void LogResponseWithPrivateNotCacheable(this ILogger logger) internal static void ResponseWithPrivateNotCacheable(this ILogger logger)
{ {
_logResponseWithPrivateNotCacheable(logger, null); _responseWithPrivateNotCacheable(logger, null);
} }
internal static void LogResponseWithUnsuccessfulStatusCodeNotCacheable(this ILogger logger, int statusCode) internal static void ResponseWithUnsuccessfulStatusCodeNotCacheable(this ILogger logger, int statusCode)
{ {
_logResponseWithUnsuccessfulStatusCodeNotCacheable(logger, statusCode, null); _responseWithUnsuccessfulStatusCodeNotCacheable(logger, statusCode, null);
} }
internal static void LogNotModifiedIfNoneMatchStar(this ILogger logger) internal static void NotModifiedIfNoneMatchStar(this ILogger logger)
{ {
_logNotModifiedIfNoneMatchStar(logger, null); _notModifiedIfNoneMatchStar(logger, null);
} }
internal static void LogNotModifiedIfNoneMatchMatched(this ILogger logger, EntityTagHeaderValue etag) internal static void NotModifiedIfNoneMatchMatched(this ILogger logger, EntityTagHeaderValue etag)
{ {
_logNotModifiedIfNoneMatchMatched(logger, etag, null); _notModifiedIfNoneMatchMatched(logger, etag, null);
} }
internal static void LogNotModifiedIfModifiedSinceSatisfied(this ILogger logger, DateTimeOffset lastModified, DateTimeOffset ifModifiedSince) internal static void NotModifiedIfModifiedSinceSatisfied(this ILogger logger, DateTimeOffset lastModified, DateTimeOffset ifModifiedSince)
{ {
_logNotModifiedIfModifiedSinceSatisfied(logger, lastModified, ifModifiedSince, null); _notModifiedIfModifiedSinceSatisfied(logger, lastModified, ifModifiedSince, null);
} }
internal static void LogNotModifiedServed(this ILogger logger) internal static void NotModifiedServed(this ILogger logger)
{ {
_logNotModifiedServed(logger, null); _notModifiedServed(logger, null);
} }
internal static void LogCachedResponseServed(this ILogger logger) internal static void CachedResponseServed(this ILogger logger)
{ {
_logCachedResponseServed(logger, null); _cachedResponseServed(logger, null);
} }
internal static void LogGatewayTimeoutServed(this ILogger logger) internal static void GatewayTimeoutServed(this ILogger logger)
{ {
_logGatewayTimeoutServed(logger, null); _gatewayTimeoutServed(logger, null);
} }
internal static void LogNoResponseServed(this ILogger logger) internal static void NoResponseServed(this ILogger logger)
{ {
_logNoResponseServed(logger, null); _noResponseServed(logger, null);
} }
internal static void LogVaryByRulesUpdated(this ILogger logger, string headers, string queryKeys) internal static void VaryByRulesUpdated(this ILogger logger, string headers, string queryKeys)
{ {
_logVaryByRulesUpdated(logger, headers, queryKeys, null); _varyByRulesUpdated(logger, headers, queryKeys, null);
} }
internal static void LogResponseCached(this ILogger logger) internal static void ResponseCached(this ILogger logger)
{ {
_logResponseCached(logger, null); _responseCached(logger, null);
} }
internal static void LogResponseNotCached(this ILogger logger) internal static void LogResponseNotCached(this ILogger logger)
{ {
_logResponseNotCached(logger, null); _responseNotCached(logger, null);
} }
internal static void LogResponseContentLengthMismatchNotCached(this ILogger logger) internal static void ResponseContentLengthMismatchNotCached(this ILogger logger)
{ {
_logResponseContentLengthMismatchNotCached(logger, null); _responseContentLengthMismatchNotCached(logger, null);
} }
internal static void LogExpirationInfiniteMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge) internal static void ExpirationInfiniteMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge)
{ {
_logExpirationInfiniteMaxStaleSatisfied(logger, age, maxAge, null); _expirationInfiniteMaxStaleSatisfied(logger, age, maxAge, null);
} }
} }
} }

View File

@ -17,14 +17,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Verify the method // Verify the method
if (!HttpMethods.IsGet(request.Method) && !HttpMethods.IsHead(request.Method)) if (!HttpMethods.IsGet(request.Method) && !HttpMethods.IsHead(request.Method))
{ {
context.Logger.LogRequestMethodNotCacheable(request.Method); context.Logger.RequestMethodNotCacheable(request.Method);
return false; return false;
} }
// Verify existence of authorization headers // Verify existence of authorization headers
if (!StringValues.IsNullOrEmpty(request.Headers[HeaderNames.Authorization])) if (!StringValues.IsNullOrEmpty(request.Headers[HeaderNames.Authorization]))
{ {
context.Logger.LogRequestWithAuthorizationNotCacheable(); context.Logger.RequestWithAuthorizationNotCacheable();
return false; return false;
} }
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
{ {
if (HeaderUtilities.ContainsCacheDirective(request.Headers[HeaderNames.CacheControl], CacheControlHeaderValue.NoCacheString)) if (HeaderUtilities.ContainsCacheDirective(request.Headers[HeaderNames.CacheControl], CacheControlHeaderValue.NoCacheString))
{ {
context.Logger.LogRequestWithNoCacheNotCacheable(); context.Logger.RequestWithNoCacheNotCacheable();
return false; return false;
} }
} }
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Support for legacy HTTP 1.0 cache directive // Support for legacy HTTP 1.0 cache directive
if (HeaderUtilities.ContainsCacheDirective(request.Headers[HeaderNames.Pragma], CacheControlHeaderValue.NoCacheString)) if (HeaderUtilities.ContainsCacheDirective(request.Headers[HeaderNames.Pragma], CacheControlHeaderValue.NoCacheString))
{ {
context.Logger.LogRequestWithPragmaNoCacheNotCacheable(); context.Logger.RequestWithPragmaNoCacheNotCacheable();
return false; return false;
} }
} }
@ -70,21 +70,21 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Only cache pages explicitly marked with public // Only cache pages explicitly marked with public
if (!HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.PublicString)) if (!HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.PublicString))
{ {
context.Logger.LogResponseWithoutPublicNotCacheable(); context.Logger.ResponseWithoutPublicNotCacheable();
return false; return false;
} }
// Check response no-store // Check response no-store
if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoStoreString)) if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoStoreString))
{ {
context.Logger.LogResponseWithNoStoreNotCacheable(); context.Logger.ResponseWithNoStoreNotCacheable();
return false; return false;
} }
// Check no-cache // Check no-cache
if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoCacheString)) if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoCacheString))
{ {
context.Logger.LogResponseWithNoCacheNotCacheable(); context.Logger.ResponseWithNoCacheNotCacheable();
return false; return false;
} }
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Do not cache responses with Set-Cookie headers // Do not cache responses with Set-Cookie headers
if (!StringValues.IsNullOrEmpty(response.Headers[HeaderNames.SetCookie])) if (!StringValues.IsNullOrEmpty(response.Headers[HeaderNames.SetCookie]))
{ {
context.Logger.LogResponseWithSetCookieNotCacheable(); context.Logger.ResponseWithSetCookieNotCacheable();
return false; return false;
} }
@ -101,21 +101,21 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
var varyHeader = response.Headers[HeaderNames.Vary]; var varyHeader = response.Headers[HeaderNames.Vary];
if (varyHeader.Count == 1 && string.Equals(varyHeader, "*", StringComparison.OrdinalIgnoreCase)) if (varyHeader.Count == 1 && string.Equals(varyHeader, "*", StringComparison.OrdinalIgnoreCase))
{ {
context.Logger.LogResponseWithVaryStarNotCacheable(); context.Logger.ResponseWithVaryStarNotCacheable();
return false; return false;
} }
// Check private // Check private
if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.PrivateString)) if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.PrivateString))
{ {
context.Logger.LogResponseWithPrivateNotCacheable(); context.Logger.ResponseWithPrivateNotCacheable();
return false; return false;
} }
// Check response code // Check response code
if (response.StatusCode != StatusCodes.Status200OK) if (response.StatusCode != StatusCodes.Status200OK)
{ {
context.Logger.LogResponseWithUnsuccessfulStatusCodeNotCacheable(response.StatusCode); context.Logger.ResponseWithUnsuccessfulStatusCodeNotCacheable(response.StatusCode);
return false; return false;
} }
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
!context.ResponseMaxAge.HasValue && !context.ResponseMaxAge.HasValue &&
context.ResponseTime.Value >= context.ResponseExpires) context.ResponseTime.Value >= context.ResponseExpires)
{ {
context.Logger.LogExpirationExpiresExceeded(context.ResponseTime.Value, context.ResponseExpires.Value); context.Logger.ExpirationExpiresExceeded(context.ResponseTime.Value, context.ResponseExpires.Value);
return false; return false;
} }
} }
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Validate shared max age // Validate shared max age
if (age >= context.ResponseSharedMaxAge) if (age >= context.ResponseSharedMaxAge)
{ {
context.Logger.LogExpirationSharedMaxAgeExceeded(age, context.ResponseSharedMaxAge.Value); context.Logger.ExpirationSharedMaxAgeExceeded(age, context.ResponseSharedMaxAge.Value);
return false; return false;
} }
else if (!context.ResponseSharedMaxAge.HasValue) else if (!context.ResponseSharedMaxAge.HasValue)
@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Validate max age // Validate max age
if (age >= context.ResponseMaxAge) if (age >= context.ResponseMaxAge)
{ {
context.Logger.LogExpirationMaxAgeExceeded(age, context.ResponseMaxAge.Value); context.Logger.ExpirationMaxAgeExceeded(age, context.ResponseMaxAge.Value);
return false; return false;
} }
else if (!context.ResponseMaxAge.HasValue) else if (!context.ResponseMaxAge.HasValue)
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Validate expiration // Validate expiration
if (context.ResponseTime.Value >= context.ResponseExpires) if (context.ResponseTime.Value >= context.ResponseExpires)
{ {
context.Logger.LogExpirationExpiresExceeded(context.ResponseTime.Value, context.ResponseExpires.Value); context.Logger.ExpirationExpiresExceeded(context.ResponseTime.Value, context.ResponseExpires.Value);
return false; return false;
} }
} }
@ -174,7 +174,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
if (HeaderUtilities.TryParseSeconds(requestCacheControlHeaders, CacheControlHeaderValue.MinFreshString, out minFresh)) if (HeaderUtilities.TryParseSeconds(requestCacheControlHeaders, CacheControlHeaderValue.MinFreshString, out minFresh))
{ {
age += minFresh.Value; age += minFresh.Value;
context.Logger.LogExpirationMinFreshAdded(minFresh.Value); context.Logger.ExpirationMinFreshAdded(minFresh.Value);
} }
// Validate shared max age, this overrides any max age settings for shared caches // Validate shared max age, this overrides any max age settings for shared caches
@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
if (age >= cachedSharedMaxAge) if (age >= cachedSharedMaxAge)
{ {
// shared max age implies must revalidate // shared max age implies must revalidate
context.Logger.LogExpirationSharedMaxAgeExceeded(age, cachedSharedMaxAge.Value); context.Logger.ExpirationSharedMaxAgeExceeded(age, cachedSharedMaxAge.Value);
return false; return false;
} }
else if (!cachedSharedMaxAge.HasValue) else if (!cachedSharedMaxAge.HasValue)
@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
if (HeaderUtilities.ContainsCacheDirective(cachedCacheControlHeaders, CacheControlHeaderValue.MustRevalidateString) if (HeaderUtilities.ContainsCacheDirective(cachedCacheControlHeaders, CacheControlHeaderValue.MustRevalidateString)
|| HeaderUtilities.ContainsCacheDirective(cachedCacheControlHeaders, CacheControlHeaderValue.ProxyRevalidateString)) || HeaderUtilities.ContainsCacheDirective(cachedCacheControlHeaders, CacheControlHeaderValue.ProxyRevalidateString))
{ {
context.Logger.LogExpirationMustRevalidate(age, lowestMaxAge.Value); context.Logger.ExpirationMustRevalidate(age, lowestMaxAge.Value);
return false; return false;
} }
@ -214,18 +214,18 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
// Request allows stale values with no age limit // Request allows stale values with no age limit
if (maxStaleExist && !requestMaxStale.HasValue) if (maxStaleExist && !requestMaxStale.HasValue)
{ {
context.Logger.LogExpirationInfiniteMaxStaleSatisfied(age, lowestMaxAge.Value); context.Logger.ExpirationInfiniteMaxStaleSatisfied(age, lowestMaxAge.Value);
return true; return true;
} }
// Request allows stale values with age limit // Request allows stale values with age limit
if (requestMaxStale.HasValue && age - lowestMaxAge < requestMaxStale) if (requestMaxStale.HasValue && age - lowestMaxAge < requestMaxStale)
{ {
context.Logger.LogExpirationMaxStaleSatisfied(age, lowestMaxAge.Value, requestMaxStale.Value); context.Logger.ExpirationMaxStaleSatisfied(age, lowestMaxAge.Value, requestMaxStale.Value);
return true; return true;
} }
context.Logger.LogExpirationMaxAgeExceeded(age, lowestMaxAge.Value); context.Logger.ExpirationMaxAgeExceeded(age, lowestMaxAge.Value);
return false; return false;
} }
else if (!cachedMaxAge.HasValue && !requestMaxAge.HasValue) else if (!cachedMaxAge.HasValue && !requestMaxAge.HasValue)
@ -235,7 +235,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
if (HeaderUtilities.TryParseDate(context.CachedResponseHeaders[HeaderNames.Expires].ToString(), out expires) && if (HeaderUtilities.TryParseDate(context.CachedResponseHeaders[HeaderNames.Expires].ToString(), out expires) &&
context.ResponseTime.Value >= expires) context.ResponseTime.Value >= expires)
{ {
context.Logger.LogExpirationExpiresExceeded(context.ResponseTime.Value, expires); context.Logger.ExpirationExpiresExceeded(context.ResponseTime.Value, expires);
return false; return false;
} }
} }

View File

@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
// Check conditional request rules // Check conditional request rules
if (ContentIsNotModified(context)) if (ContentIsNotModified(context))
{ {
_logger.LogNotModifiedServed(); _logger.NotModifiedServed();
context.HttpContext.Response.StatusCode = StatusCodes.Status304NotModified; context.HttpContext.Response.StatusCode = StatusCodes.Status304NotModified;
} }
else else
@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
context.HttpContext.Abort(); context.HttpContext.Abort();
} }
} }
_logger.LogCachedResponseServed(); _logger.CachedResponseServed();
} }
return true; return true;
} }
@ -221,12 +221,12 @@ namespace Microsoft.AspNetCore.ResponseCaching
if (HeaderUtilities.ContainsCacheDirective(context.HttpContext.Request.Headers[HeaderNames.CacheControl], CacheControlHeaderValue.OnlyIfCachedString)) if (HeaderUtilities.ContainsCacheDirective(context.HttpContext.Request.Headers[HeaderNames.CacheControl], CacheControlHeaderValue.OnlyIfCachedString))
{ {
_logger.LogGatewayTimeoutServed(); _logger.GatewayTimeoutServed();
context.HttpContext.Response.StatusCode = StatusCodes.Status504GatewayTimeout; context.HttpContext.Response.StatusCode = StatusCodes.Status504GatewayTimeout;
return true; return true;
} }
_logger.LogNoResponseServed(); _logger.NoResponseServed();
return false; return false;
} }
@ -279,7 +279,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
} }
// Always overwrite the CachedVaryByRules to update the expiry information // Always overwrite the CachedVaryByRules to update the expiry information
_logger.LogVaryByRulesUpdated(normalizedVaryHeaders, normalizedVaryQueryKeys); _logger.VaryByRulesUpdated(normalizedVaryHeaders, normalizedVaryQueryKeys);
storeVaryByEntry = true; storeVaryByEntry = true;
context.StorageVaryKey = _keyProvider.CreateStorageVaryByKey(context); context.StorageVaryKey = _keyProvider.CreateStorageVaryByKey(context);
@ -349,12 +349,12 @@ namespace Microsoft.AspNetCore.ResponseCaching
} }
context.CachedResponse.Body = bufferStream; context.CachedResponse.Body = bufferStream;
_logger.LogResponseCached(); _logger.ResponseCached();
await _cache.SetAsync(context.StorageVaryKey ?? context.BaseKey, context.CachedResponse, context.CachedResponseValidFor); await _cache.SetAsync(context.StorageVaryKey ?? context.BaseKey, context.CachedResponse, context.CachedResponseValidFor);
} }
else else
{ {
_logger.LogResponseContentLengthMismatchNotCached(); _logger.ResponseContentLengthMismatchNotCached();
} }
} }
else else
@ -453,7 +453,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
{ {
if (ifNoneMatchHeader.Count == 1 && StringSegment.Equals(ifNoneMatchHeader[0], EntityTagHeaderValue.Any.Tag, StringComparison.OrdinalIgnoreCase)) if (ifNoneMatchHeader.Count == 1 && StringSegment.Equals(ifNoneMatchHeader[0], EntityTagHeaderValue.Any.Tag, StringComparison.OrdinalIgnoreCase))
{ {
context.Logger.LogNotModifiedIfNoneMatchStar(); context.Logger.NotModifiedIfNoneMatchStar();
return true; return true;
} }
@ -468,7 +468,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
var requestETag = ifNoneMatchEtags[i]; var requestETag = ifNoneMatchEtags[i];
if (eTag.Compare(requestETag, useStrongComparison: false)) if (eTag.Compare(requestETag, useStrongComparison: false))
{ {
context.Logger.LogNotModifiedIfNoneMatchMatched(requestETag); context.Logger.NotModifiedIfNoneMatchMatched(requestETag);
return true; return true;
} }
} }
@ -490,7 +490,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
if (HeaderUtilities.TryParseDate(ifModifiedSince.ToString(), out modifiedSince) && if (HeaderUtilities.TryParseDate(ifModifiedSince.ToString(), out modifiedSince) &&
modified <= modifiedSince) modified <= modifiedSince)
{ {
context.Logger.LogNotModifiedIfModifiedSinceSatisfied(modified, modifiedSince); context.Logger.NotModifiedIfModifiedSinceSatisfied(modified, modifiedSince);
return true; return true;
} }
} }

View File

@ -19,14 +19,45 @@ namespace Microsoft.AspNetCore.ResponseCompression.Internal
static ResponseCompressionLoggingExtensions() static ResponseCompressionLoggingExtensions()
{ {
_noAcceptEncoding = LoggerMessage.Define(LogLevel.Debug, 1, "No response compression available, the Accept-Encoding header is missing or invalid."); _noAcceptEncoding = LoggerMessage.Define(
_noCompressionForHttps = LoggerMessage.Define(LogLevel.Debug, 2, "No response compression available for HTTPS requests. See ResponseCompressionOptions.EnableForHttps."); LogLevel.Debug,
_requestAcceptsCompression = LoggerMessage.Define(LogLevel.Trace, 3, "This request accepts compression."); new EventId(1, "NoAcceptEncoding"),
_noCompressionDueToHeader = LoggerMessage.Define<string>(LogLevel.Debug, 4, "Response compression disabled due to the {header} header."); "No response compression available, the Accept-Encoding header is missing or invalid.");
_noCompressionForContentType = LoggerMessage.Define<string>(LogLevel.Debug, 5, "Response compression is not enabled for the Content-Type '{header}'.");
_shouldCompressResponse = LoggerMessage.Define(LogLevel.Trace, 6, "Response compression is available for this Content-Type."); _noCompressionForHttps = LoggerMessage.Define(
_noCompressionProvider = LoggerMessage.Define(LogLevel.Debug, 7, "No matching response compression provider found."); LogLevel.Debug,
_compressWith = LoggerMessage.Define<string>(LogLevel.Debug, 8, "The response will be compressed with '{provider}'."); new EventId(2, "NoCompressionForHttps"),
"No response compression available for HTTPS requests. See ResponseCompressionOptions.EnableForHttps.");
_requestAcceptsCompression = LoggerMessage.Define(
LogLevel.Trace,
new EventId(3, "RequestAcceptsCompression"),
"This request accepts compression.");
_noCompressionDueToHeader = LoggerMessage.Define<string>(
LogLevel.Debug,
new EventId(4, "NoCompressionDueToHeader"),
"Response compression disabled due to the {header} header.");
_noCompressionForContentType = LoggerMessage.Define<string>(
LogLevel.Debug,
new EventId(5, "NoCompressionForContentType"),
"Response compression is not enabled for the Content-Type '{header}'.");
_shouldCompressResponse = LoggerMessage.Define(
LogLevel.Trace,
new EventId(6, "ShouldCompressResponse"),
"Response compression is available for this Content-Type.");
_noCompressionProvider = LoggerMessage.Define(
LogLevel.Debug,
new EventId(7, "NoCompressionProvider"),
"No matching response compression provider found.");
_compressWith = LoggerMessage.Define<string>(
LogLevel.Debug,
new EventId(8, "CompressWith"),
"The response will be compressed with '{provider}'.");
} }
public static void NoAcceptEncoding(this ILogger logger) public static void NoAcceptEncoding(this ILogger logger)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -11,14 +11,14 @@ namespace Microsoft.AspNetCore.Rewrite.Logging
private static readonly Action<ILogger, string, Exception> _requestContinueResults; private static readonly Action<ILogger, string, Exception> _requestContinueResults;
private static readonly Action<ILogger, string, int, Exception> _requestResponseComplete; private static readonly Action<ILogger, string, int, Exception> _requestResponseComplete;
private static readonly Action<ILogger, string, Exception> _requestStopRules; private static readonly Action<ILogger, string, Exception> _requestStopRules;
private static readonly Action<ILogger, string, Exception> _urlRewriteDidNotMatchRule; private static readonly Action<ILogger, string, Exception> _urlRewriteNotMatchedRule;
private static readonly Action<ILogger, string, Exception> _urlRewriteMatchedRule; private static readonly Action<ILogger, string, Exception> _urlRewriteMatchedRule;
private static readonly Action<ILogger, Exception> _modRewriteDidNotMatchRule; private static readonly Action<ILogger, Exception> _modRewriteNotMatchedRule;
private static readonly Action<ILogger, Exception> _modRewriteMatchedRule; private static readonly Action<ILogger, Exception> _modRewriteMatchedRule;
private static readonly Action<ILogger, Exception> _redirectedToHttps; private static readonly Action<ILogger, Exception> _redirectedToHttps;
private static readonly Action<ILogger, Exception> _redirectedToWww; private static readonly Action<ILogger, Exception> _redirectedToWww;
private static readonly Action<ILogger, string, Exception> _redirectSummary; private static readonly Action<ILogger, string, Exception> _redirectedRequest;
private static readonly Action<ILogger, string, Exception> _rewriteSummary; private static readonly Action<ILogger, string, Exception> _rewrittenRequest;
private static readonly Action<ILogger, string, Exception> _abortedRequest; private static readonly Action<ILogger, string, Exception> _abortedRequest;
private static readonly Action<ILogger, string, Exception> _customResponse; private static readonly Action<ILogger, string, Exception> _customResponse;
@ -26,67 +26,67 @@ namespace Microsoft.AspNetCore.Rewrite.Logging
{ {
_requestContinueResults = LoggerMessage.Define<string>( _requestContinueResults = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
1, new EventId(1, "RequestContinueResults"),
"Request is continuing in applying rules. Current url is {currentUrl}"); "Request is continuing in applying rules. Current url is {currentUrl}");
_requestResponseComplete = LoggerMessage.Define<string, int>( _requestResponseComplete = LoggerMessage.Define<string, int>(
LogLevel.Debug, LogLevel.Debug,
2, new EventId(2, "RequestResponseComplete"),
"Request is done processing. Location header '{Location}' with status code '{StatusCode}'."); "Request is done processing. Location header '{Location}' with status code '{StatusCode}'.");
_requestStopRules = LoggerMessage.Define<string>( _requestStopRules = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
3, new EventId(3, "RequestStopRules"),
"Request is done applying rules. Url was rewritten to {rewrittenUrl}"); "Request is done applying rules. Url was rewritten to {rewrittenUrl}");
_urlRewriteDidNotMatchRule = LoggerMessage.Define<string>( _urlRewriteNotMatchedRule = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
4, new EventId(4, "UrlRewriteNotMatchedRule"),
"Request did not match current rule '{Name}'."); "Request did not match current rule '{Name}'.");
_urlRewriteMatchedRule = LoggerMessage.Define<string>( _urlRewriteMatchedRule = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
5, new EventId(5, "UrlRewriteMatchedRule"),
"Request matched current UrlRewriteRule '{Name}'."); "Request matched current UrlRewriteRule '{Name}'.");
_modRewriteDidNotMatchRule = LoggerMessage.Define( _modRewriteNotMatchedRule = LoggerMessage.Define(
LogLevel.Debug, LogLevel.Debug,
6, new EventId(6, "ModRewriteNotMatchedRule"),
"Request matched current ModRewriteRule."); "Request matched current ModRewriteRule.");
_modRewriteMatchedRule = LoggerMessage.Define( _modRewriteMatchedRule = LoggerMessage.Define(
LogLevel.Debug, LogLevel.Debug,
7, new EventId(7, "ModRewriteMatchedRule"),
"Request matched current ModRewriteRule."); "Request matched current ModRewriteRule.");
_redirectedToHttps = LoggerMessage.Define( _redirectedToHttps = LoggerMessage.Define(
LogLevel.Information, LogLevel.Information,
8, new EventId(8, "RedirectedToHttps"),
"Request redirected to HTTPS"); "Request redirected to HTTPS");
_redirectSummary = LoggerMessage.Define<string>( _redirectedRequest = LoggerMessage.Define<string>(
LogLevel.Information, LogLevel.Information,
9, new EventId(9, "RedirectedRequest"),
"Request was redirected to {redirectedUrl}"); "Request was redirected to {redirectedUrl}");
_rewriteSummary = LoggerMessage.Define<string>( _rewrittenRequest = LoggerMessage.Define<string>(
LogLevel.Information, LogLevel.Information,
10, new EventId(10, "RewritetenRequest"),
"Request was rewritten to {rewrittenUrl}"); "Request was rewritten to {rewrittenUrl}");
_abortedRequest = LoggerMessage.Define<string>( _abortedRequest = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
11, new EventId(11, "AbortedRequest"),
"Request to {requestedUrl} was aborted"); "Request to {requestedUrl} was aborted");
_customResponse = LoggerMessage.Define<string>( _customResponse = LoggerMessage.Define<string>(
LogLevel.Debug, LogLevel.Debug,
12, new EventId(12, "CustomResponse"),
"Request to {requestedUrl} was ended"); "Request to {requestedUrl} was ended");
_redirectedToWww = LoggerMessage.Define( _redirectedToWww = LoggerMessage.Define(
LogLevel.Information, LogLevel.Information,
13, new EventId(13, "RedirectedToWww"),
"Request redirected to www"); "Request redirected to www");
} }
@ -105,9 +105,9 @@ namespace Microsoft.AspNetCore.Rewrite.Logging
_requestStopRules(logger, rewrittenUrl, null); _requestStopRules(logger, rewrittenUrl, null);
} }
public static void UrlRewriteDidNotMatchRule(this ILogger logger, string name) public static void UrlRewriteNotMatchedRule(this ILogger logger, string name)
{ {
_urlRewriteDidNotMatchRule(logger, name, null); _urlRewriteNotMatchedRule(logger, name, null);
} }
public static void UrlRewriteMatchedRule(this ILogger logger, string name) public static void UrlRewriteMatchedRule(this ILogger logger, string name)
@ -115,9 +115,9 @@ namespace Microsoft.AspNetCore.Rewrite.Logging
_urlRewriteMatchedRule(logger, name, null); _urlRewriteMatchedRule(logger, name, null);
} }
public static void ModRewriteDidNotMatchRule(this ILogger logger) public static void ModRewriteNotMatchedRule(this ILogger logger)
{ {
_modRewriteDidNotMatchRule(logger, null); _modRewriteNotMatchedRule(logger, null);
} }
public static void ModRewriteMatchedRule(this ILogger logger) public static void ModRewriteMatchedRule(this ILogger logger)
@ -135,14 +135,14 @@ namespace Microsoft.AspNetCore.Rewrite.Logging
_redirectedToWww(logger, null); _redirectedToWww(logger, null);
} }
public static void RedirectedSummary(this ILogger logger, string redirectedUrl) public static void RedirectedRequest(this ILogger logger, string redirectedUrl)
{ {
_redirectSummary(logger, redirectedUrl, null); _redirectedRequest(logger, redirectedUrl, null);
} }
public static void RewriteSummary(this ILogger logger, string rewrittenUrl) public static void RewrittenRequest(this ILogger logger, string rewrittenUrl)
{ {
_rewriteSummary(logger, rewrittenUrl, null); _rewrittenRequest(logger, rewrittenUrl, null);
} }
public static void AbortedRequest(this ILogger logger, string requestedUrl) public static void AbortedRequest(this ILogger logger, string requestedUrl)

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
if (!initMatchRes.Success) if (!initMatchRes.Success)
{ {
context.Logger?.ModRewriteDidNotMatchRule(); context.Logger?.ModRewriteNotMatchedRule();
return; return;
} }
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
var condResult = ConditionEvaluator.Evaluate(Conditions, context, initMatchRes.BackReferences); var condResult = ConditionEvaluator.Evaluate(Conditions, context, initMatchRes.BackReferences);
if (!condResult.Success) if (!condResult.Success)
{ {
context.Logger?.ModRewriteDidNotMatchRule(); context.Logger?.ModRewriteNotMatchedRule();
return; return;
} }
} }

View File

@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite
if (!initMatchResults.Success) if (!initMatchResults.Success)
{ {
context.Logger?.UrlRewriteDidNotMatchRule(Name); context.Logger?.UrlRewriteNotMatchedRule(Name);
return; return;
} }
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite
condResult = ConditionEvaluator.Evaluate(Conditions, context, initMatchResults.BackReferences); condResult = ConditionEvaluator.Evaluate(Conditions, context, initMatchResults.BackReferences);
if (!condResult.Success) if (!condResult.Success)
{ {
context.Logger?.UrlRewriteDidNotMatchRule(Name); context.Logger?.UrlRewriteNotMatchedRule(Name);
return; return;
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal
response.Headers[HeaderNames.Location] = pathBase + newPath + context.HttpContext.Request.QueryString; response.Headers[HeaderNames.Location] = pathBase + newPath + context.HttpContext.Request.QueryString;
} }
context.Logger?.RedirectedSummary(newPath); context.Logger?.RedirectedRequest(newPath);
} }
} }
} }

View File

@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal
} }
} }
context.Logger?.RewriteSummary(result); context.Logger?.RewrittenRequest(result);
} }
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -23,51 +23,51 @@ namespace Microsoft.Extensions.Logging
static LoggingExtensions() static LoggingExtensions()
{ {
_errorClosingTheSession = LoggerMessage.Define( _errorClosingTheSession = LoggerMessage.Define(
eventId: 1, eventId: new EventId(1, "ErrorClosingTheSession"),
logLevel: LogLevel.Error, logLevel: LogLevel.Error,
formatString: "Error closing the session."); formatString: "Error closing the session.");
_accessingExpiredSession = LoggerMessage.Define<string>( _accessingExpiredSession = LoggerMessage.Define<string>(
eventId: 2, eventId: new EventId(2, "AccessingExpiredSession"),
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
formatString: "Accessing expired session, Key:{sessionKey}"); formatString: "Accessing expired session, Key:{sessionKey}");
_sessionStarted = LoggerMessage.Define<string, string>( _sessionStarted = LoggerMessage.Define<string, string>(
eventId: 3, eventId: new EventId(3, "SessionStarted"),
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
formatString: "Session started; Key:{sessionKey}, Id:{sessionId}"); formatString: "Session started; Key:{sessionKey}, Id:{sessionId}");
_sessionLoaded = LoggerMessage.Define<string, string, int>( _sessionLoaded = LoggerMessage.Define<string, string, int>(
eventId: 4, eventId: new EventId(4, "SessionLoaded"),
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
formatString: "Session loaded; Key:{sessionKey}, Id:{sessionId}, Count:{count}"); formatString: "Session loaded; Key:{sessionKey}, Id:{sessionId}, Count:{count}");
_sessionStored = LoggerMessage.Define<string, string, int>( _sessionStored = LoggerMessage.Define<string, string, int>(
eventId: 5, eventId: new EventId(5, "SessionStored"),
logLevel: LogLevel.Debug, logLevel: LogLevel.Debug,
formatString: "Session stored; Key:{sessionKey}, Id:{sessionId}, Count:{count}"); formatString: "Session stored; Key:{sessionKey}, Id:{sessionId}, Count:{count}");
_sessionCacheReadException = LoggerMessage.Define<string>( _sessionCacheReadException = LoggerMessage.Define<string>(
eventId: 6, eventId: new EventId(6, "SessionCacheReadException"),
logLevel: LogLevel.Error, logLevel: LogLevel.Error,
formatString: "Session cache read exception, Key:{sessionKey}"); formatString: "Session cache read exception, Key:{sessionKey}");
_errorUnprotectingCookie = LoggerMessage.Define( _errorUnprotectingCookie = LoggerMessage.Define(
eventId: 7, eventId: new EventId(7, "ErrorUnprotectingCookie"),
logLevel: LogLevel.Warning, logLevel: LogLevel.Warning,
formatString: "Error unprotecting the session cookie."); formatString: "Error unprotecting the session cookie.");
_sessionLoadingTimeout = LoggerMessage.Define( _sessionLoadingTimeout = LoggerMessage.Define(
eventId: 8, eventId: new EventId(8, "SessionLoadingTimeout"),
logLevel: LogLevel.Warning, logLevel: LogLevel.Warning,
formatString: "Loading the session timed out."); formatString: "Loading the session timed out.");
_sessionCommitTimeout = LoggerMessage.Define( _sessionCommitTimeout = LoggerMessage.Define(
eventId: 9, eventId: new EventId(9, "SessionCommitTimeout"),
logLevel: LogLevel.Warning, logLevel: LogLevel.Warning,
formatString: "Committing the session timed out."); formatString: "Committing the session timed out.");
_sessionCommitCanceled = LoggerMessage.Define( _sessionCommitCanceled = LoggerMessage.Define(
eventId: 10, eventId: new EventId(10, "SessionCommitCanceled"),
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
formatString: "Committing the session was canceled."); formatString: "Committing the session was canceled.");
_sessionRefreshTimeout = LoggerMessage.Define( _sessionRefreshTimeout = LoggerMessage.Define(
eventId: 11, eventId: new EventId(11, "SessionRefreshTimeout"),
logLevel: LogLevel.Warning, logLevel: LogLevel.Warning,
formatString: "Refreshing the session timed out."); formatString: "Refreshing the session timed out.");
_sessionRefreshCanceled = LoggerMessage.Define( _sessionRefreshCanceled = LoggerMessage.Define(
eventId: 12, eventId: new EventId(12, "SessionRefreshCanceled"),
logLevel: LogLevel.Information, logLevel: LogLevel.Information,
formatString: "Refreshing the session was canceled."); formatString: "Refreshing the session was canceled.");
} }