diff --git a/src/Ocelot/Requester/Middleware/HttpRequesterMiddleware.cs b/src/Ocelot/Requester/Middleware/HttpRequesterMiddleware.cs index e26d6a5b3..9c83a93f0 100644 --- a/src/Ocelot/Requester/Middleware/HttpRequesterMiddleware.cs +++ b/src/Ocelot/Requester/Middleware/HttpRequesterMiddleware.cs @@ -39,15 +39,14 @@ public async Task Invoke(HttpContext httpContext) private void CreateLogBasedOnResponse(Response response) { - if (response.Data?.StatusCode <= HttpStatusCode.BadRequest) + var message= () =>$"{(int)response.Data.StatusCode} ({response.Data.ReasonPhrase}) status code, request uri: {response.Data.RequestMessage?.RequestUri}"; + if (response.Data?.StatusCode < HttpStatusCode.BadRequest) { - Logger.LogInformation(() => - $"{(int)response.Data.StatusCode} ({response.Data.ReasonPhrase}) status code, request uri: {response.Data.RequestMessage?.RequestUri}"); + Logger.LogInformation(message); } else if (response.Data?.StatusCode >= HttpStatusCode.BadRequest) { - Logger.LogWarning( - () => $"{(int)response.Data.StatusCode} ({response.Data.ReasonPhrase}) status code, request uri: {response.Data.RequestMessage?.RequestUri}"); + Logger.LogWarning(message); } } }