Skip to content

Commit

Permalink
Fix a bug in HttpRequesterMiddleware.cs,
Browse files Browse the repository at this point in the history
BadRequest should be logged as debug!
  • Loading branch information
masoud-bahrami authored Jan 30, 2024
1 parent f4803c2 commit e3d3635
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Ocelot/Requester/Middleware/HttpRequesterMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ public async Task Invoke(HttpContext httpContext)

private void CreateLogBasedOnResponse(Response<HttpResponseMessage> 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);
}
}
}
Expand Down

0 comments on commit e3d3635

Please sign in to comment.