diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs index 5a72a142e7..f747354e7b 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Authentication.Cookies if (ticket == null) { - _logger.WriteWarning(@"Unprotect ticket failed"); + _logger.LogWarning(@"Unprotect ticket failed"); return null; } @@ -62,14 +62,14 @@ namespace Microsoft.AspNet.Authentication.Cookies Claim claim = ticket.Principal.Claims.FirstOrDefault(c => c.Type.Equals(SessionIdClaim)); if (claim == null) { - _logger.WriteWarning(@"SessionId missing"); + _logger.LogWarning(@"SessionId missing"); return null; } _sessionKey = claim.Value; ticket = await Options.SessionStore.RetrieveAsync(_sessionKey); if (ticket == null) { - _logger.WriteWarning(@"Identity missing in session store"); + _logger.LogWarning(@"Identity missing in session store"); return null; } } diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs index ba933d2358..21df592538 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Authentication.Cookies Options.CookieManager = new ChunkingCookieManager(); } - _logger = loggerFactory.Create(typeof(CookieAuthenticationMiddleware).FullName); + _logger = loggerFactory.CreateLogger(typeof(CookieAuthenticationMiddleware).FullName); } protected override AuthenticationHandler CreateHandler() diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs index 8e193befee..6a51d85e97 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Authentication.OAuth AuthenticationTicket ticket = await AuthenticateAsync(); if (ticket == null) { - Logger.WriteWarning("Invalid return state, unable to redirect."); + Logger.LogWarning("Invalid return state, unable to redirect."); Response.StatusCode = 500; return true; } @@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Authentication.OAuth var value = query.Get("error"); if (!string.IsNullOrEmpty(value)) { - Logger.WriteVerbose("Remote server returned an error: " + Request.QueryString); + Logger.LogVerbose("Remote server returned an error: " + Request.QueryString); // TODO: Fail request rather than passing through? return null; } @@ -127,7 +127,7 @@ namespace Microsoft.AspNet.Authentication.OAuth if (string.IsNullOrWhiteSpace(tokens.AccessToken)) { - Logger.WriteWarning("Access token was not found"); + Logger.LogWarning("Access token was not found"); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } @@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Authentication.OAuth } catch (Exception ex) { - Logger.WriteError("Authentication failed", ex); + Logger.LogError("Authentication failed", ex); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs index b8e10ff996..8f937575f4 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs @@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Authentication.OAuth throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "TokenEndpoint")); } - Logger = loggerFactory.Create(this.GetType().FullName); + Logger = loggerFactory.CreateLogger(this.GetType().FullName); if (Options.StateDataFormat == null) { diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs index 56d3d1025d..42e6f838fb 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs @@ -155,7 +155,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer } catch (Exception ex) { - _logger.WriteError("Exception occurred while processing message", ex); + _logger.LogError("Exception occurred while processing message", ex); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the notification. if (Options.RefreshOnIssuerKeyNotFound && ex.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs index 824405e0e4..8698bf740b 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer ConfigureOptions configureOptions) : base(next, services, options, configureOptions) { - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); if (Options.Notifications == null) { Options.Notifications = new OAuthBearerAuthenticationNotifications(); diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs index 543e8eeeb6..2a802ce10d 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect ConfigureOptions configureOptions) : base(next, services, options, configureOptions) { - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); if (string.IsNullOrWhiteSpace(Options.TokenValidationParameters.AuthenticationType)) { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs index 884dfa733f..046232b9ea 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect string redirectUri = notification.ProtocolMessage.CreateLogoutRequestUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { - _logger.WriteWarning("The logout redirect URI is malformed: {0}", (redirectUri ?? "null")); + _logger.LogWarning("The logout redirect URI is malformed: {0}", (redirectUri ?? "null")); } Response.Redirect(redirectUri); @@ -195,7 +195,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect string redirectUri = notification.ProtocolMessage.CreateAuthenticationRequestUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { - _logger.WriteWarning("Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute) returned 'false', redirectUri is: {0}", (redirectUri ?? "null")); + _logger.LogWarning("Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute) returned 'false', redirectUri is: {0}", (redirectUri ?? "null")); } Response.Redirect(redirectUri); @@ -262,7 +262,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect AuthenticationProperties properties = GetPropertiesFromState(openIdConnectMessage.State); if (properties == null) { - _logger.WriteWarning("The state field is missing or invalid."); + _logger.LogWarning("The state field is missing or invalid."); return null; } @@ -279,7 +279,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // OpenIdConnect protocol allows a Code to be received without the id_token if (string.IsNullOrWhiteSpace(openIdConnectMessage.IdToken)) { - _logger.WriteWarning("The id_token is missing."); + _logger.LogWarning("The id_token is missing."); return null; } @@ -424,7 +424,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } catch (Exception exception) { - _logger.WriteError("Exception occurred while processing message", exception); + _logger.LogError("Exception occurred while processing message", exception); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the notification. if (Options.RefreshOnIssuerKeyNotFound && exception.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) @@ -511,7 +511,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } catch (Exception ex) { - _logger.WriteWarning("Failed to un-protect the nonce cookie.", ex); + _logger.LogWarning("Failed to un-protect the nonce cookie.", ex); } } } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs index c6361295b0..355fb84b27 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Authentication.Twitter if (requestToken == null) { - _logger.WriteWarning("Invalid state"); + _logger.LogWarning("Invalid state"); return null; } @@ -71,20 +71,20 @@ namespace Microsoft.AspNet.Authentication.Twitter string returnedToken = query.Get("oauth_token"); if (string.IsNullOrWhiteSpace(returnedToken)) { - _logger.WriteWarning("Missing oauth_token"); + _logger.LogWarning("Missing oauth_token"); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } if (returnedToken != requestToken.Token) { - _logger.WriteWarning("Unmatched token"); + _logger.LogWarning("Unmatched token"); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } string oauthVerifier = query.Get("oauth_verifier"); if (string.IsNullOrWhiteSpace(oauthVerifier)) { - _logger.WriteWarning("Missing or blank oauth_verifier"); + _logger.LogWarning("Missing or blank oauth_verifier"); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } @@ -120,7 +120,7 @@ namespace Microsoft.AspNet.Authentication.Twitter } catch (Exception ex) { - _logger.WriteError("Authentication failed", ex); + _logger.LogError("Authentication failed", ex); return new AuthenticationTicket(properties, Options.AuthenticationScheme); } } @@ -180,7 +180,7 @@ namespace Microsoft.AspNet.Authentication.Twitter } else { - _logger.WriteError("requestToken CallbackConfirmed!=true"); + _logger.LogError("requestToken CallbackConfirmed!=true"); } } @@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Authentication.Twitter AuthenticationTicket model = await AuthenticateAsync(); if (model == null) { - _logger.WriteWarning("Invalid return state, unable to redirect."); + _logger.LogWarning("Invalid return state, unable to redirect."); Response.StatusCode = 500; return true; } @@ -224,7 +224,7 @@ namespace Microsoft.AspNet.Authentication.Twitter private async Task ObtainRequestTokenAsync(string consumerKey, string consumerSecret, string callBackUri, AuthenticationProperties properties) { - _logger.WriteVerbose("ObtainRequestToken"); + _logger.LogVerbose("ObtainRequestToken"); string nonce = Guid.NewGuid().ToString("N"); @@ -285,7 +285,7 @@ namespace Microsoft.AspNet.Authentication.Twitter { // https://dev.twitter.com/docs/api/1/post/oauth/access_token - _logger.WriteVerbose("ObtainAccessToken"); + _logger.LogVerbose("ObtainAccessToken"); string nonce = Guid.NewGuid().ToString("N"); @@ -342,7 +342,7 @@ namespace Microsoft.AspNet.Authentication.Twitter if (!response.IsSuccessStatusCode) { - _logger.WriteError("AccessToken request failed with a status code of " + response.StatusCode); + _logger.LogError("AccessToken request failed with a status code of " + response.StatusCode); response.EnsureSuccessStatusCode(); // throw } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs index 6869080921..2efdaff968 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs @@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Authentication.Twitter throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "ConsumerKey")); } - _logger = loggerFactory.Create(typeof(TwitterAuthenticationMiddleware).FullName); + _logger = loggerFactory.CreateLogger(typeof(TwitterAuthenticationMiddleware).FullName); if (Options.Notifications == null) { diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index f3d13d33fe..e2c619b39e 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -408,7 +408,7 @@ namespace Microsoft.AspNet.Authentication string correlationCookie = Request.Cookies[correlationKey]; if (string.IsNullOrWhiteSpace(correlationCookie)) { - logger.WriteWarning("{0} cookie not found.", correlationKey); + logger.LogWarning("{0} cookie not found.", correlationKey); return false; } @@ -424,7 +424,7 @@ namespace Microsoft.AspNet.Authentication correlationKey, out correlationExtra)) { - logger.WriteWarning("{0} state property not found.", correlationKey); + logger.LogWarning("{0} state property not found.", correlationKey); return false; } @@ -432,7 +432,7 @@ namespace Microsoft.AspNet.Authentication if (!string.Equals(correlationCookie, correlationExtra, StringComparison.Ordinal)) { - logger.WriteWarning("{0} correlation cookie and state property mismatch.", correlationKey); + logger.LogWarning("{0} correlation cookie and state property mismatch.", correlationKey); return false; }